Changeset 222
- Timestamp:
- 23/05/07 15:09:05 (18 months ago)
- Location:
- trunk/mio
- Files:
-
- 3 modified
-
mio.h (modified) (2 diffs)
-
mio_impl.h (modified) (3 diffs)
-
mio_select.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/mio/mio.h
r3 r222 27 27 28 28 #include "ac-stdint.h" 29 30 /* jabberd2 Windows DLL */ 31 #ifndef JABBERD2_API 32 # ifdef _WIN32 33 # ifdef JABBERD2_EXPORTS 34 # define JABBERD2_API __declspec(dllexport) 35 # else /* JABBERD2_EXPORTS */ 36 # define JABBERD2_API __declspec(dllimport) 37 # endif /* JABBERD2_EXPORTS */ 38 # else /* _WIN32 */ 39 # define JABBERD2_API extern 40 # endif /* _WIN32 */ 41 #endif /* JABBERD2_API */ 42 43 #ifdef _WIN32 44 # define MIO_MAXFD FD_SETSIZE 45 #else 46 # define MIO_MAXFD 1024 47 #endif 29 48 30 49 #include <stdio.h> … … 110 129 111 130 /** create/free the mio subsytem */ 112 mio_t mio_new(int maxfd); /* returns NULL if failed */131 JABBERD2_API mio_t mio_new(int maxfd); /* returns NULL if failed */ 113 132 114 133 #define mio_free(m) (*m)->mio_free(m) -
trunk/mio/mio_impl.h
r141 r222 26 26 #include "util/inaddr.h" 27 27 28 /* win32 wrappers around strerror */ 29 #ifdef _WIN32 30 #define close(x) closesocket(x) 31 #ifdef MIO_DEBUG 32 char *ws_strerror(int code) 33 { 34 static char buff[128]; 35 int len; 36 if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 37 NULL, WSAGetLastError(), 0, buff, 38 sizeof(buff), NULL)) 39 return buff; 40 return strerror(code); 41 } 42 #define strerror(x) ws_strerror(x) 43 #endif 44 #endif /* _WIN32 */ 45 28 46 /** our internal wrapper around a fd */ 29 47 typedef enum { … … 392 410 393 411 /* gotta wait till later */ 412 #ifdef _WIN32 413 if(flag == -1 && WSAGetLastError() == WSAEWOULDBLOCK) 414 #else 394 415 if(flag == -1 && errno == EINPROGRESS) 416 #endif 395 417 { 396 418 mio_fd = _mio_setup_fd(m,fd,app,arg); … … 432 454 mio_t m; 433 455 456 /* init winsock if we are in Windows */ 457 #ifdef _WIN32 458 WSADATA wsaData; 459 if (WSAStartup(MAKEWORD( 1, 1 ), &wsaData)) 460 return NULL; 461 #endif 462 434 463 /* allocate and zero out main memory */ 435 464 if((m = malloc(sizeof(struct mio_priv_st))) == NULL) return NULL; -
trunk/mio/mio_select.h
r3 r222 34 34 } \ 35 35 m->highfd = 0; \ 36 m->lowfd = m->maxfd; \ 36 37 } \ 37 38 \ … … 39 40 { \ 40 41 if(fd > m->highfd) m->highfd = fd; \ 42 if(fd < m->lowfd) m->lowfd = fd; \ 41 43 return &m->fds[fd].mio_fd; \ 42 44 } \ … … 51 53 tv.tv_sec = t; \ 52 54 tv.tv_usec = 0; \ 53 return select(m->highfd + 1, &m->rfds_out, &m->wfds_out, NULL, &tv); \55 return select(m->highfd + 1, &m->rfds_out, &m->wfds_out, &m->wfds_out, &tv); \ 54 56 } 55 57 … … 58 60 #define MIO_VARS \ 59 61 struct mio_priv_fd_st *fds; \ 62 int lowfd; \ 60 63 int highfd; \ 61 64 fd_set rfds_in, wfds_in, rfds_out, wfds_out; … … 106 109 107 110 #define MIO_ITERATE_RESULTS(m, retval, iter) \ 108 for(iter = 0; iter <= MIO(m)->highfd; iter++)111 for(iter = MIO(m)->lowfd; iter <= MIO(m)->highfd; iter++) 109 112 110 113 #define MIO_ITERATOR_FD(m, iter) \
