Changeset 3
- Timestamp:
- 19/04/06 00:48:49 (3 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 23 modified
-
c2s/c2s.c (modified) (25 diffs)
-
c2s/c2s.h (modified) (3 diffs)
-
c2s/main.c (modified) (4 diffs)
-
configure.in (modified) (1 diff)
-
mio/Makefile.am (modified) (1 diff)
-
mio/mio.c (modified) (2 diffs)
-
mio/mio_common.c (added)
-
mio/mio_epoll.c (added)
-
mio/mio_epoll.h (added)
-
mio/mio.h (modified) (1 diff)
-
mio/mio_impl.h (added)
-
mio/mio_poll.c (added)
-
mio/mio_poll.h (modified) (1 diff)
-
mio/mio_select.c (added)
-
mio/mio_select.h (modified) (1 diff)
-
resolver/resolver.c (modified) (10 diffs)
-
resolver/resolver.h (modified) (1 diff)
-
router/main.c (modified) (2 diffs)
-
router/router.c (modified) (13 diffs)
-
router/router.h (modified) (3 diffs)
-
s2s/in.c (modified) (16 diffs)
-
s2s/main.c (modified) (10 diffs)
-
s2s/out.c (modified) (18 diffs)
-
s2s/router.c (modified) (9 diffs)
-
s2s/s2s.h (modified) (4 diffs)
-
sm/main.c (modified) (2 diffs)
-
sm/object.c (modified) (1 diff)
-
sm/sm.c (modified) (8 diffs)
-
sm/sm.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/c2s/c2s.c
r2 r3 41 41 42 42 case event_READ: 43 log_debug(ZONE, "reading from %d", sess->fd );43 log_debug(ZONE, "reading from %d", sess->fd->fd); 44 44 45 45 /* check rate limits */ … … 50 50 if(!sess->rate_log) { 51 51 if(s->state >= state_STREAM && sess->jid != NULL) 52 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] is being byte rate limited", sess->fd , sess->jid);52 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] is being byte rate limited", sess->fd->fd, sess->jid); 53 53 else 54 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] is being byte rate limited", sess->fd , sess->ip, sess->port);54 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] is being byte rate limited", sess->fd->fd, sess->ip, sess->port); 55 55 56 56 sess->rate_log = 1; 57 57 } 58 58 59 log_debug(ZONE, "%d is throttled, delaying read", sess->fd );59 log_debug(ZONE, "%d is throttled, delaying read", sess->fd->fd); 60 60 61 61 buf->len = 0; … … 70 70 71 71 /* do the read */ 72 len = recv(sess->fd , buf->data, buf->len, 0);72 len = recv(sess->fd->fd, buf->data, buf->len, 0); 73 73 74 74 if(len < 0) { … … 79 79 80 80 if(s->state >= state_STREAM && sess->jid != NULL) 81 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] read error: %s (%d)", sess->fd , jid_full(sess->jid), strerror(errno), errno);81 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] read error: %s (%d)", sess->fd->fd, jid_full(sess->jid), strerror(errno), errno); 82 82 else 83 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] read error: %s (%d)", sess->fd , sess->ip, sess->port, strerror(errno), errno);83 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] read error: %s (%d)", sess->fd->fd, sess->ip, sess->port, strerror(errno), errno); 84 84 85 85 sx_kill(s); … … 102 102 103 103 case event_WRITE: 104 log_debug(ZONE, "writing to %d", sess->fd );105 106 len = send(sess->fd , buf->data, buf->len, 0);104 log_debug(ZONE, "writing to %d", sess->fd->fd); 105 106 len = send(sess->fd->fd, buf->data, buf->len, 0); 107 107 if(len >= 0) { 108 108 log_debug(ZONE, "%d bytes written", len); … … 114 114 115 115 if(s->state >= state_OPEN && sess->jid != NULL) 116 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] write error: %s (%d)", sess->fd , jid_full(sess->jid), strerror(errno), errno);116 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] write error: %s (%d)", sess->fd->fd, jid_full(sess->jid), strerror(errno), errno); 117 117 else 118 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s. port=%d] write error: %s (%d)", sess->fd , sess->ip, sess->port, strerror(errno), errno);118 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s. port=%d] write error: %s (%d)", sess->fd->fd, sess->ip, sess->port, strerror(errno), errno); 119 119 120 120 sx_kill(s); … … 125 125 sxe = (sx_error_t *) data; 126 126 if(sess->jid != NULL) 127 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] error: %s (%s)", sess->fd , jid_full(sess->jid), sxe->generic, sxe->specific);127 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s] error: %s (%s)", sess->fd->fd, jid_full(sess->jid), sxe->generic, sxe->specific); 128 128 else 129 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] error: %s (%s)", sess->fd , sess->ip, sess->port, sxe->generic, sxe->specific);129 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] error: %s (%s)", sess->fd->fd, sess->ip, sess->port, sxe->generic, sxe->specific); 130 130 131 131 break; … … 337 337 case event_CLOSED: 338 338 mio_close(sess->c2s->mio, sess->fd); 339 340 break; 339 return -1; 341 340 } 342 341 … … 344 343 } 345 344 346 static int _c2s_client_accept_check(c2s_t c2s, int fd, char *ip) {345 static int _c2s_client_accept_check(c2s_t c2s, mio_fd_t fd, char *ip) { 347 346 rate_t rt; 348 347 349 348 if(access_check(c2s->access, ip) == 0) { 350 log_write(c2s->log, LOG_NOTICE, "[%d] [%s] access denied by configuration", fd , ip);349 log_write(c2s->log, LOG_NOTICE, "[%d] [%s] access denied by configuration", fd->fd, ip); 351 350 return 1; 352 351 } … … 361 360 362 361 if(rate_check(rt) == 0) { 363 log_write(c2s->log, LOG_NOTICE, "[%d] [%s] is being rate limited", fd , ip);362 log_write(c2s->log, LOG_NOTICE, "[%d] [%s] is being rate limited", fd->fd, ip); 364 363 return 1; 365 364 } … … 371 370 } 372 371 373 static int _c2s_client_mio_callback(mio_t m, mio_action_t a, int fd, void *data, void *arg) {372 static int _c2s_client_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg) { 374 373 sess_t sess = (sess_t) arg; 375 374 c2s_t c2s = (c2s_t) arg; … … 379 378 switch(a) { 380 379 case action_READ: 381 log_debug(ZONE, "read action on fd %d", fd );380 log_debug(ZONE, "read action on fd %d", fd->fd); 382 381 383 382 /* they did something */ 384 383 sess->last_activity = time(NULL); 385 384 386 ioctl(fd , FIONREAD, &nbytes);385 ioctl(fd->fd, FIONREAD, &nbytes); 387 386 if(nbytes == 0) { 388 387 sx_kill(sess->s); … … 393 392 394 393 case action_WRITE: 395 log_debug(ZONE, "write action on fd %d", fd );394 log_debug(ZONE, "write action on fd %d", fd->fd); 396 395 397 396 return sx_can_write(sess->s); 398 397 399 398 case action_CLOSE: 400 log_debug(ZONE, "close action on fd %d", fd );401 402 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] disconnect", sess->fd , sess->ip, sess->port);399 log_debug(ZONE, "close action on fd %d", fd->fd); 400 401 log_write(sess->c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] disconnect", sess->fd->fd, sess->ip, sess->port); 403 402 404 403 /* tell the sm to close their session */ … … 415 414 416 415 case action_ACCEPT: 417 log_debug(ZONE, "accept action on fd %d", fd );418 419 getpeername(fd , (struct sockaddr *) &sa, &namelen);416 log_debug(ZONE, "accept action on fd %d", fd->fd); 417 418 getpeername(fd->fd, (struct sockaddr *) &sa, &namelen); 420 419 port = j_inet_getport(&sa); 421 420 422 log_write(c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] connect", fd , (char *) data, port);421 log_write(c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] connect", fd->fd, (char *) data, port); 423 422 424 423 if(_c2s_client_accept_check(c2s, fd, (char *) data) != 0) … … 438 437 sess->last_activity = time(NULL); 439 438 440 sess->s = sx_new(c2s->sx_env, fd , _c2s_client_sx_callback, (void *) sess);439 sess->s = sx_new(c2s->sx_env, fd->fd, _c2s_client_sx_callback, (void *) sess); 441 440 mio_app(m, fd, _c2s_client_mio_callback, (void *) sess); 442 441 … … 445 444 446 445 /* find out which port this is */ 447 getsockname(fd , (struct sockaddr *) &sa, &namelen);446 getsockname(fd->fd, (struct sockaddr *) &sa, &namelen); 448 447 port = j_inet_getport(&sa); 449 448 450 449 /* remember it */ 451 sprintf(sess->skey, "%d", fd );450 sprintf(sess->skey, "%d", fd->fd); 452 451 xhash_put(c2s->sessions, sess->skey, (void *) sess); 453 452 … … 543 542 544 543 case event_READ: 545 log_debug(ZONE, "reading from %d", c2s->fd );544 log_debug(ZONE, "reading from %d", c2s->fd->fd); 546 545 547 546 /* do the read */ 548 len = recv(c2s->fd , buf->data, buf->len, 0);547 len = recv(c2s->fd->fd, buf->data, buf->len, 0); 549 548 550 549 if(len < 0) { … … 554 553 } 555 554 556 log_write(c2s->log, LOG_NOTICE, "[%d] [router] read error: %s (%d)", c2s->fd , strerror(errno), errno);555 log_write(c2s->log, LOG_NOTICE, "[%d] [router] read error: %s (%d)", c2s->fd->fd, strerror(errno), errno); 557 556 558 557 sx_kill(s); … … 575 574 576 575 case event_WRITE: 577 log_debug(ZONE, "writing to %d", c2s->fd );578 579 len = send(c2s->fd , buf->data, buf->len, 0);576 log_debug(ZONE, "writing to %d", c2s->fd->fd); 577 578 len = send(c2s->fd->fd, buf->data, buf->len, 0); 580 579 if(len >= 0) { 581 580 log_debug(ZONE, "%d bytes written", len); … … 586 585 return 0; 587 586 588 log_write(c2s->log, LOG_NOTICE, "[%d] [router] write error: %s (%d)", c2s->fd , strerror(errno), errno);587 log_write(c2s->log, LOG_NOTICE, "[%d] [router] write error: %s (%d)", c2s->fd->fd, strerror(errno), errno); 589 588 590 589 sx_kill(s); … … 690 689 if(c2s->local_port != 0) { 691 690 c2s->server_fd = mio_listen(c2s->mio, c2s->local_port, c2s->local_ip, _c2s_client_mio_callback, (void *) c2s); 692 if(c2s->server_fd < 0)691 if(c2s->server_fd == NULL) 693 692 log_write(c2s->log, LOG_ERR, "[%s, port=%d] failed to listen", c2s->local_ip, c2s->local_port); 694 693 else 695 694 log_write(c2s->log, LOG_NOTICE, "[%s, port=%d] listening for connections", c2s->local_ip, c2s->local_port); 696 695 } else 697 c2s->server_fd = -1;696 c2s->server_fd = NULL; 698 697 699 698 #ifdef HAVE_SSL 700 699 if(c2s->local_ssl_port != 0 && c2s->local_pemfile != NULL) { 701 700 c2s->server_ssl_fd = mio_listen(c2s->mio, c2s->local_ssl_port, c2s->local_ip, _c2s_client_mio_callback, (void *) c2s); 702 if(c2s->server_ssl_fd < 0)701 if(c2s->server_ssl_fd == NULL) 703 702 log_write(c2s->log, LOG_ERR, "[%s, port=%d] failed to listen", c2s->local_ip, c2s->local_ssl_port); 704 703 else 705 704 log_write(c2s->log, LOG_NOTICE, "[%s, port=%d] listening for SSL connections", c2s->local_ip, c2s->local_ssl_port); 706 705 } else 707 c2s->server_ssl_fd = -1;706 c2s->server_ssl_fd = NULL; 708 707 #endif 709 708 } 710 709 711 710 #ifdef HAVE_SSL 712 if(c2s->server_fd < 0 && c2s->server_ssl_fd < 0) {711 if(c2s->server_fd == NULL && c2s->server_ssl_fd == NULL) { 713 712 log_write(c2s->log, LOG_ERR, "both normal and SSL ports are disabled, nothing to do!"); 714 713 #else 715 if(c2s->server_fd < 0) {714 if(c2s->server_fd == NULL) { 716 715 log_write(c2s->log, LOG_ERR, "server port is disabled, nothing to do!"); 717 716 #endif … … 1026 1025 case event_CLOSED: 1027 1026 mio_close(c2s->mio, c2s->fd); 1028 break;1027 return -1; 1029 1028 } 1030 1029 … … 1032 1031 } 1033 1032 1034 int c2s_router_mio_callback(mio_t m, mio_action_t a, int fd, void *data, void *arg) {1033 int c2s_router_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg) { 1035 1034 c2s_t c2s = (c2s_t) arg; 1036 1035 int nbytes; … … 1038 1037 switch(a) { 1039 1038 case action_READ: 1040 log_debug(ZONE, "read action on fd %d", fd );1041 1042 ioctl(fd , FIONREAD, &nbytes);1039 log_debug(ZONE, "read action on fd %d", fd->fd); 1040 1041 ioctl(fd->fd, FIONREAD, &nbytes); 1043 1042 if(nbytes == 0) { 1044 1043 sx_kill(c2s->router); … … 1049 1048 1050 1049 case action_WRITE: 1051 log_debug(ZONE, "write action on fd %d", fd );1050 log_debug(ZONE, "write action on fd %d", fd->fd); 1052 1051 return sx_can_write(c2s->router); 1053 1052 1054 1053 case action_CLOSE: 1055 log_debug(ZONE, "close action on fd %d", fd );1054 log_debug(ZONE, "close action on fd %d", fd->fd); 1056 1055 log_write(c2s->log, LOG_NOTICE, "connection to router closed"); 1057 1056 -
trunk/c2s/c2s.h
r2 r3 44 44 c2s_t c2s; 45 45 46 intfd;46 mio_fd_t fd; 47 47 48 48 char skey[10]; … … 106 106 /** router's conn */ 107 107 sx_t router; 108 intfd;108 mio_fd_t fd; 109 109 110 110 /** listening sockets */ 111 intserver_fd;111 mio_fd_t server_fd; 112 112 #ifdef HAVE_SSL 113 intserver_ssl_fd;113 mio_fd_t server_ssl_fd; 114 114 #endif 115 115 … … 213 213 extern sig_atomic_t c2s_lost_router; 214 214 215 int c2s_router_mio_callback(mio_t m, mio_action_t a, int fd, void *data, void *arg);215 int c2s_router_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg); 216 216 int c2s_router_sx_callback(sx_t s, sx_event_t e, void *data, void *arg); 217 217 -
trunk/c2s/main.c
r2 r3 221 221 222 222 c2s->fd = mio_connect(c2s->mio, c2s->router_port, c2s->router_ip, c2s_router_mio_callback, (void *) c2s); 223 if(c2s->fd < 0) {223 if(c2s->fd == NULL) { 224 224 if(errno == ECONNREFUSED) 225 225 c2s_lost_router = 1; … … 228 228 } 229 229 230 c2s->router = sx_new(c2s->sx_env, c2s->fd , c2s_router_sx_callback, (void *) c2s);230 c2s->router = sx_new(c2s->sx_env, c2s->fd->fd, c2s_router_sx_callback, (void *) c2s); 231 231 sx_client_init(c2s->router, 0, NULL, NULL, NULL, "1.0"); 232 232 … … 383 383 384 384 if(c2s->io_check_idle > 0 && now > sess->last_activity + c2s->io_check_idle) { 385 log_write(c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] timed out", sess->fd , sess->ip, sess->port);385 log_write(c2s->log, LOG_NOTICE, "[%d] [%s, port=%d] timed out", sess->fd->fd, sess->ip, sess->port); 386 386 387 387 sx_error(sess->s, stream_err_HOST_GONE, "connection timed out"); … … 392 392 393 393 if(c2s->io_check_keepalive > 0 && now > sess->last_activity + c2s->io_check_keepalive && sess->s->state >= state_STREAM) { 394 log_debug(ZONE, "sending keepalive for %d", sess->fd );394 log_debug(ZONE, "sending keepalive for %d", sess->fd->fd); 395 395 396 396 sx_raw_write(sess->s, " ", 1); -
trunk/configure.in
r2 r3 611 611 dnl 612 612 AC_ARG_ENABLE(mio, AC_HELP_STRING([--enable-mio=BACKEND], [use BACKEND to drive MIO]), 613 mio_check=$enableval, mio_check=' poll select')613 mio_check=$enableval, mio_check='epoll poll select') 614 614 615 615 mio_backend='' 616 616 for backend in $mio_check ; do 617 if test "x-$mio_backend" = "x-" ; then 618 case x-$backend in 619 620 x-poll) 621 AC_CHECK_HEADERS(poll.h) 622 if test "x-$ac_cv_header_poll_h" = "x-yes" ; then 623 AC_CHECK_FUNCS(poll,[ 624 mio_backend='poll' 625 AC_DEFINE(MIO_POLL,1,[Define to 1 if you want to use 'poll' for non-blocking I/O.])]) 626 fi 627 ;; 628 629 x-select) 630 AC_CHECK_HEADERS(sys/select.h) 631 if test "x-$ac_cv_header_sys_select_h" = "x-yes" ; then 632 AC_CHECK_FUNCS(select, have_select=yes) 633 fi 634 635 if test "x-$have_select" != "x-yes" -a "x-$ac_cv_header_winsock2_h" = "x-yes" ; then 636 AC_MSG_CHECKING([for select in ws2_32]) 637 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]], 638 [[select(0,0,0,0,0)]])], 639 [AC_MSG_RESULT(yes) 640 have_select=yes], 641 AC_MSG_RESULT(no)) 642 fi 643 644 if test "x-$have_select" = "x-yes" ; then 645 mio_backend='select' 646 AC_DEFINE(MIO_SELECT,1,[Define to 1 if you want to use 'select' for non-blocking I/O.]) 647 fi 648 ;; 649 esac 650 fi 617 case x-$backend in 618 619 x-epoll) 620 AC_CHECK_HEADERS(sys/epoll.h) 621 if test "x-$ac_cv_header_sys_epoll_h" = "x-yes" ; then 622 AC_CHECK_FUNCS(epoll_create,[ 623 mio_backend='epoll' 624 AC_DEFINE(MIO_EPOLL,1,[Define to 1 if you want to use 'epoll' for non-blocking I/O.])]) 625 fi 626 ;; 627 628 x-poll) 629 AC_CHECK_HEADERS(poll.h) 630 if test "x-$ac_cv_header_poll_h" = "x-yes" ; then 631 AC_CHECK_FUNCS(poll,[ 632 mio_backend='poll' 633 AC_DEFINE(MIO_POLL,1,[Define to 1 if you want to use 'poll' for non-blocking I/O.])]) 634 fi 635 ;; 636 637 x-select) 638 AC_CHECK_HEADERS(sys/select.h) 639 if test "x-$ac_cv_header_sys_select_h" = "x-yes" ; then 640 AC_CHECK_FUNCS(select, have_select=yes) 641 fi 642 643 if test "x-$have_select" != "x-yes" -a "x-$ac_cv_header_winsock2_h" = "x-yes" ; then 644 AC_MSG_CHECKING([for select in ws2_32]) 645 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]], 646 [[select(0,0,0,0,0)]])], 647 [AC_MSG_RESULT(yes) 648 have_select=yes], 649 AC_MSG_RESULT(no)) 650 fi 651 652 if test "x-$have_select" = "x-yes" ; then 653 mio_backend='select' 654 AC_DEFINE(MIO_SELECT,1,[Define to 1 if you want to use 'select' for non-blocking I/O.]) 655 fi 656 ;; 657 esac 651 658 done 652 659 -
trunk/mio/Makefile.am
r2 r3 3 3 noinst_HEADERS = mio.h mio_poll.h mio_select.h 4 4 5 libmio_la_SOURCES = mio.c 5 libmio_la_SOURCES = mio.c mio_epoll.c mio_poll.c mio_select.c 6 6 libmio_la_LIBADD = @LDFLAGS@ -
trunk/mio/mio.c
r2 r3 2 2 * jabberd - Jabber Open Source Server 3 3 * Copyright (c) 2002 Jeremie Miller, Thomas Muldowney, 4 * Ryan Eatmon, Robert Norris 4 * Ryan Eatmon, Robert Norris, Christof Meerwald 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify … … 30 30 #include "mio.h" 31 31 32 #include "util/inaddr.h" 32 33 mio_t mio_epoll_new(int maxfd); 34 mio_t mio_poll_new(int maxfd); 35 mio_t mio_select_new(int maxfd); 36 37 mio_t mio_new(int maxfd) 38 { 39 mio_t m = NULL; 40 41 #ifdef MIO_EPOLL 42 m = mio_epoll_new(maxfd); 43 if (m != NULL) return m; 44 #endif 45 46 #ifdef MIO_SELECT 47 m = mio_select_new(maxfd); 48 if (m != NULL) return m; 49 #endif 33 50 34 51 #ifdef MIO_POLL 35 #include "mio_poll.h" 36 #endif 37 #ifdef MIO_SELECT 38 #include "mio_select.h" 52 m = mio_poll_new(maxfd); 53 if (m != NULL) return m; 39 54 #endif 40 55 41 /** our internal wrapper around a fd */ 42 typedef enum { 43 type_CLOSED = 0x00, 44 type_NORMAL = 0x01, 45 type_LISTEN = 0x02, 46 type_CONNECT = 0x10, 47 type_CONNECT_READ = 0x11, 48 type_CONNECT_WRITE = 0x12 49 } mio_type_t; 50 struct mio_fd_st 51 { 52 mio_type_t type; 53 /* app event handler and data */ 54 mio_handler_t app; 55 void *arg; 56 }; 57 58 /** now define our master data type */ 59 struct mio_st 60 { 61 struct mio_fd_st *fds; 62 int maxfd; 63 int highfd; 64 MIO_VARS 65 }; 66 67 /* lazy factor */ 68 #define FD(m,f) m->fds[f] 69 #define ACT(m,f,a,d) (*(FD(m,f).app))(m,a,f,d,FD(m,f).arg) 70 71 /* temp debug outputter */ 72 #define ZONE __LINE__ 73 #ifndef MIO_DEBUG 74 #define MIO_DEBUG 0 75 #endif 76 #define mio_debug if(MIO_DEBUG) _mio_debug 77 void _mio_debug(int line, const char *msgfmt, ...) 78 { 79 va_list ap; 80 va_start(ap,msgfmt); 81 fprintf(stderr,"mio.c#%d: ",line); 82 vfprintf(stderr,msgfmt,ap); 83 fprintf(stderr,"\n"); 56 return m; 84 57 } 85 86 MIO_FUNCS87 88 /** internal close function */89 void mio_close(mio_t m, int fd)90 {91 mio_debug(ZONE,"actually closing fd #%d",fd);92 93 /* take out of poll sets */94 MIO_REMOVE_FD(m, fd);95 96 /* let the app know, it must process any waiting write data it has and free it's arg */97 ACT(m, fd, action_CLOSE, NULL);98 99 /* close the socket, and reset all memory */100 close(fd);101 memset(&FD(m,fd), 0, sizeof(struct mio_fd_st));102 }103 104 /** internally accept an incoming connection from a listen sock */105 void _mio_accept(mio_t m, int fd)106 {107 struct sockaddr_storage serv_addr;108 socklen_t addrlen = (socklen_t) sizeof(serv_addr);109 int newfd, dupfd;110 char ip[INET6_ADDRSTRLEN];111 112 mio_debug(ZONE, "accepting on fd #%d", fd);113
