diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-05 11:03:33 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-06 15:21:33 -0700 |
| commit | 916ba1ab23aa50b855fd795f095eaedb328e84d9 (patch) | |
| tree | b764e37145e7caf8f2fe7d1a3999ab6798c3a095 /src/supplemental/http/http_conn.c | |
| parent | 7ecb0e4a74bbb3d49ebe37a14b2534a242cb930a (diff) | |
| download | nng-916ba1ab23aa50b855fd795f095eaedb328e84d9.tar.gz nng-916ba1ab23aa50b855fd795f095eaedb328e84d9.tar.bz2 nng-916ba1ab23aa50b855fd795f095eaedb328e84d9.zip | |
fixes #396 illumos doesn't build (missing NNG_PLATFORM_POSIX ON)
fixes #397 Need to cast zoneid
fixes #395 sun is predefined on illumos/Solaris
fixes #394 alloca needs to #include <alloca.h>
fixes #399 Cannot use SVR4.2 specific msghdr
fixes #402 getpeerucred needs a NULL initialized ucred
fixes #403 syntax error in posix_tcp - attempt to return void
fixes #407 illumos getegid wrong
fixes #406 nni_idhash_count is dead code
fixes #404 idhash typedef redeclared
fixes #405 warning: newline not last character in file
This is basically a slew of related bug fixes required to make this
work on illumos. Note that the fixes are not "complete", because
more work is required to support port events given that epoll is busted
on illumos.
We also fixed a bunch of things that aren't actually "bugs" per se, but
really just warnings. Silencing them makes things better for everyone.
Apparently not all compilers are equally happy with redundant (but
otherwise identical) typedefs; we use structs in some places instead of
shorter type names to silence these complaints.
Note that IPC permissions (the mode bits on the socket vnode) are not
validated on SunOS systems. This change includes documentation to reflect
that.
Diffstat (limited to 'src/supplemental/http/http_conn.c')
| -rw-r--r-- | src/supplemental/http/http_conn.c | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c index a3039d0d..0de40e10 100644 --- a/src/supplemental/http/http_conn.c +++ b/src/supplemental/http/http_conn.c @@ -36,14 +36,21 @@ enum write_flavor { HTTP_WR_RES, }; +typedef void (*http_read_fn)(void *, nni_aio *); +typedef void (*http_write_fn)(void *, nni_aio *); +typedef void (*http_close_fn)(void *); +typedef void (*http_fini_fn)(void *); +typedef bool (*http_verified_fn)(void *); +typedef int (*http_addr_fn)(void *, nni_sockaddr *); + typedef struct nni_http_tran { - void (*h_read)(void *, nni_aio *); - void (*h_write)(void *, nni_aio *); - int (*h_sock_addr)(void *, nni_sockaddr *); - int (*h_peer_addr)(void *, nni_sockaddr *); - bool (*h_verified)(void *); - void (*h_close)(void *); - void (*h_fini)(void *); + http_read_fn h_read; + http_write_fn h_write; + http_addr_fn h_sock_addr; + http_addr_fn h_peer_addr; + http_verified_fn h_verified; + http_close_fn h_close; + http_fini_fn h_fini; } nni_http_tran; #define SET_RD_FLAVOR(aio, f) \ @@ -54,20 +61,18 @@ typedef struct nni_http_tran { #define GET_WR_FLAVOR(aio) (int) ((intptr_t) nni_aio_get_prov_extra(aio, 0)) struct nng_http_conn { - void *sock; - void (*rd)(void *, nni_aio *); - void (*wr)(void *, nni_aio *); - int (*sock_addr)(void *, nni_sockaddr *); - int (*peer_addr)(void *, nni_sockaddr *); - bool (*verified)(void *); - void (*close)(void *); - void (*fini)(void *); - - void *ctx; - bool closed; - - nni_list rdq; // high level http read requests - nni_list wrq; // high level http write requests + void * sock; + http_read_fn rd; + http_write_fn wr; + http_addr_fn sock_addr; + http_addr_fn peer_addr; + http_verified_fn verified; + http_close_fn close; + http_fini_fn fini; + void * ctx; + bool closed; + nni_list rdq; // high level http read requests + nni_list wrq; // high level http write requests nni_aio *rd_uaio; // user aio for read nni_aio *wr_uaio; // user aio for write @@ -715,13 +720,13 @@ nni_http_verified_tcp(void *arg) } static nni_http_tran http_tcp_ops = { - .h_read = (void *) nni_plat_tcp_pipe_recv, - .h_write = (void *) nni_plat_tcp_pipe_send, - .h_close = (void *) nni_plat_tcp_pipe_close, - .h_fini = (void *) nni_plat_tcp_pipe_fini, - .h_sock_addr = (void *) nni_plat_tcp_pipe_sockname, - .h_peer_addr = (void *) nni_plat_tcp_pipe_peername, - .h_verified = nni_http_verified_tcp, + .h_read = (http_read_fn) nni_plat_tcp_pipe_recv, + .h_write = (http_write_fn) nni_plat_tcp_pipe_send, + .h_close = (http_close_fn) nni_plat_tcp_pipe_close, + .h_fini = (http_fini_fn) nni_plat_tcp_pipe_fini, + .h_sock_addr = (http_addr_fn) nni_plat_tcp_pipe_sockname, + .h_peer_addr = (http_addr_fn) nni_plat_tcp_pipe_peername, + .h_verified = (http_verified_fn) nni_http_verified_tcp, }; int @@ -732,17 +737,18 @@ nni_http_conn_init_tcp(nni_http_conn **connp, void *tcp) #ifdef NNG_SUPP_TLS static nni_http_tran http_tls_ops = { - .h_read = (void *) nni_tls_recv, - .h_write = (void *) nni_tls_send, - .h_close = (void *) nni_tls_close, - .h_fini = (void *) nni_tls_fini, - .h_sock_addr = (void *) nni_tls_sockname, - .h_peer_addr = (void *) nni_tls_peername, - .h_verified = (void *) nni_tls_verified, + .h_read = (http_read_fn) nni_tls_recv, + .h_write = (http_write_fn) nni_tls_send, + .h_close = (http_close_fn) nni_tls_close, + .h_fini = (http_fini_fn) nni_tls_fini, + .h_sock_addr = (http_addr_fn) nni_tls_sockname, + .h_peer_addr = (http_addr_fn) nni_tls_peername, + .h_verified = (http_verified_fn) nni_tls_verified, }; int -nni_http_conn_init_tls(nni_http_conn **connp, nng_tls_config *cfg, void *tcp) +nni_http_conn_init_tls( + nni_http_conn **connp, struct nng_tls_config *cfg, void *tcp) { nni_tls *tls; int rv; @@ -756,7 +762,8 @@ nni_http_conn_init_tls(nni_http_conn **connp, nng_tls_config *cfg, void *tcp) } #else int -nni_http_conn_init_tls(nni_http_conn **connp, nng_tls_config *cfg, void *tcp) +nni_http_conn_init_tls( + nni_http_conn **connp, struct nng_tls_config *cfg, void *tcp) { NNI_ARG_UNUSED(connp); NNI_ARG_UNUSED(cfg); |
