0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 07:20:55 +01:00

libratbox: make defer_accept optional.

This commit is contained in:
William Pitcock 2012-03-17 09:48:25 -05:00
parent 77cb59b319
commit aa4737a049
6 changed files with 18 additions and 10 deletions

View file

@ -28,7 +28,7 @@
int rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile); int rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile);
int rb_init_ssl(void); int rb_init_ssl(void);
int rb_ssl_listen(rb_fde_t *F, int backlog); int rb_ssl_listen(rb_fde_t *F, int backlog, int defer_accept);
int rb_init_prng(const char *path, prng_seed_t seed_type); int rb_init_prng(const char *path, prng_seed_t seed_type);
int rb_get_random(void *buf, size_t length); int rb_get_random(void *buf, size_t length);

View file

@ -126,8 +126,8 @@ ssize_t rb_read(rb_fde_t *, void *buf, int count);
int rb_pipe(rb_fde_t **, rb_fde_t **, const char *desc); int rb_pipe(rb_fde_t **, rb_fde_t **, const char *desc);
int rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile); int rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile);
int rb_ssl_listen(rb_fde_t *, int backlog); int rb_ssl_listen(rb_fde_t *, int backlog, int defer_accept);
int rb_listen(rb_fde_t *, int backlog); int rb_listen(rb_fde_t *, int backlog, int defer_accept);
const char *rb_inet_ntop(int af, const void *src, char *dst, unsigned int size); const char *rb_inet_ntop(int af, const void *src, char *dst, unsigned int size);
int rb_inet_pton(int af, const char *src, void *dst); int rb_inet_pton(int af, const char *src, void *dst);

View file

@ -761,7 +761,7 @@ mangle_mapped_sockaddr(struct sockaddr *in)
* rb_listen() - listen on a port * rb_listen() - listen on a port
*/ */
int int
rb_listen(rb_fde_t *F, int backlog) rb_listen(rb_fde_t *F, int backlog, int defer_accept)
{ {
int result; int result;
@ -769,7 +769,7 @@ rb_listen(rb_fde_t *F, int backlog)
result = listen(F->fd, backlog); result = listen(F->fd, backlog);
#ifdef TCP_DEFER_ACCEPT #ifdef TCP_DEFER_ACCEPT
if (!result) if (defer_accept && !result)
{ {
setsockopt(F->fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &backlog, sizeof(int)); setsockopt(F->fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &backlog, sizeof(int));
} }

View file

@ -348,10 +348,14 @@ rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
} }
int int
rb_ssl_listen(rb_fde_t *F, int backlog) rb_ssl_listen(rb_fde_t *F, int backlog, int defer_accept)
{ {
int result;
result = listen(F->fd, backlog, defer_accept);
F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL; F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL;
return listen(F->fd, backlog);
return result;
} }
struct ssl_connect struct ssl_connect

View file

@ -49,7 +49,7 @@ rb_init_ssl(void)
} }
int int
rb_ssl_listen(rb_fde_t *F, int backlog) rb_ssl_listen(rb_fde_t *F, int backlog, int defer_accept)
{ {
errno = ENOSYS; errno = ENOSYS;
return -1; return -1;

View file

@ -390,10 +390,14 @@ rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
} }
int int
rb_ssl_listen(rb_fde_t *F, int backlog) rb_ssl_listen(rb_fde_t *F, int backlog, int defer_accept)
{ {
int result;
result = rb_listen(F, backlog, defer_accept);
F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL; F->type = RB_FD_SOCKET | RB_FD_LISTEN | RB_FD_SSL;
return listen(F->fd, backlog);
return result;
} }
struct ssl_connect struct ssl_connect