diff options
Diffstat (limited to 'src/microhttpd/mhd_sockets.c')
-rw-r--r-- | src/microhttpd/mhd_sockets.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/microhttpd/mhd_sockets.c b/src/microhttpd/mhd_sockets.c index 643ed849..640c59e3 100644 --- a/src/microhttpd/mhd_sockets.c +++ b/src/microhttpd/mhd_sockets.c | |||
@@ -235,3 +235,32 @@ const char* MHD_W32_strerror_winsock_(int err) | |||
235 | 235 | ||
236 | 236 | ||
237 | #endif /* MHD_WINSOCK_SOCKETS */ | 237 | #endif /* MHD_WINSOCK_SOCKETS */ |
238 | |||
239 | |||
240 | /** | ||
241 | * Add @a fd to the @a set. If @a fd is | ||
242 | * greater than @a max_fd, set @a max_fd to @a fd. | ||
243 | * | ||
244 | * @param fd file descriptor to add to the @a set | ||
245 | * @param set set to modify | ||
246 | * @param max_fd maximum value to potentially update | ||
247 | * @param fd_setsize value of FD_SETSIZE | ||
248 | * @return non-zero if succeeded, zero otherwise | ||
249 | */ | ||
250 | int | ||
251 | MHD_add_to_fd_set_ (MHD_socket fd, | ||
252 | fd_set *set, | ||
253 | MHD_socket *max_fd, | ||
254 | unsigned int fd_setsize) | ||
255 | { | ||
256 | if (NULL == set || MHD_INVALID_SOCKET == fd) | ||
257 | return 0; | ||
258 | if (!MHD_SCKT_FD_FITS_FDSET_SETSIZE_(fd, set, fd_setsize)) | ||
259 | return 0; | ||
260 | MHD_SCKT_ADD_FD_TO_FDSET_SETSIZE_(fd, set, fd_setsize); | ||
261 | if ( (NULL != max_fd) && | ||
262 | ((fd > *max_fd) || (MHD_INVALID_SOCKET == *max_fd)) ) | ||
263 | *max_fd = fd; | ||
264 | |||
265 | return !0; | ||
266 | } | ||