Commit a62879f73522a41855b893a8a390716961722a0d
1 parent
1e6a8550
compile with latest library versions, escpecialy the new socket code.
Showing
29 changed files
with
41 additions
and
13 deletions
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | |
41 | 41 | TR_CLASS(HttpWorker) { |
42 | 42 | char * id; |
43 | - TR_Sock socket; | |
43 | + TR_Socket socket; | |
44 | 44 | |
45 | 45 | TR_Cbuf pbuf; |
46 | 46 | TR_Hash asset_pool; |
... | ... | @@ -55,6 +55,7 @@ TR_CLASS(HttpWorker) { |
55 | 55 | HttpParser parser; |
56 | 56 | HttpWriter writer; |
57 | 57 | }; |
58 | +TR_INSTANCE_INIT(HttpWorker); | |
58 | 59 | |
59 | 60 | #endif // __HTTP_WORKER_H__ |
60 | 61 | ... | ... |
... | ... | @@ -35,15 +35,15 @@ |
35 | 35 | #include "trio.h" |
36 | 36 | |
37 | 37 | struct conns { |
38 | - TR_Sock sock; | |
38 | + TR_Socket sock; | |
39 | 39 | TR_Stream stream; |
40 | 40 | void * worker; |
41 | 41 | }; |
42 | 42 | |
43 | 43 | TR_CLASS(Server) { |
44 | 44 | TR_Logger logger; |
45 | - TR_Sock sock; | |
46 | - TR_Sock sockSSL; | |
45 | + TR_Socket sock; | |
46 | + TR_Socket sockSSL; | |
47 | 47 | SSL_CTX * ctx; |
48 | 48 | void * worker; |
49 | 49 | |
... | ... | @@ -53,6 +53,7 @@ TR_CLASS(Server) { |
53 | 53 | |
54 | 54 | struct conns * conns; |
55 | 55 | }; |
56 | +TR_INSTANCE_INIT(Server); | |
56 | 57 | |
57 | 58 | void serverRun(Server this); |
58 | 59 | ... | ... |
... | ... | @@ -34,15 +34,16 @@ |
34 | 34 | int |
35 | 35 | serverHandleAccept(Server this, unsigned int i) |
36 | 36 | { |
37 | - char remoteAddr[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; | |
38 | - TR_Sock acc = NULL; | |
39 | - TR_Stream st; | |
37 | + TR_Socket acc = NULL; | |
38 | + TR_Stream st; | |
40 | 39 | |
41 | 40 | if (this->nfds >= this->max_fds) { |
42 | 41 | return -1; |
43 | 42 | } |
44 | 43 | |
45 | - acc = TR_socketAccept((0 == i)? this->sock : this->sockSSL, &remoteAddr); | |
44 | + acc = (TR_Socket)TR_socketAccept((0 == i) | |
45 | + ? (TR_TcpSocket)this->sock | |
46 | + : (TR_TcpSocket)this->sockSSL); | |
46 | 47 | |
47 | 48 | if (NULL != acc && -1 != acc->handle) { |
48 | 49 | TR_socketNonblock(acc); | ... | ... |
... | ... | @@ -65,11 +65,13 @@ serverCtor(void * _this, va_list * params) |
65 | 65 | this->fds = TR_calloc(sizeof(struct pollfd), this->max_fds); |
66 | 66 | this->conns = TR_calloc(sizeof(struct conns), this->max_fds); |
67 | 67 | |
68 | - this->sock = TR_new(TR_Sock, this->logger, port); | |
68 | + this->sock = TR_new(TR_TcpSocket, this->logger, "0.0.0.0", port, 0); | |
69 | 69 | TR_socketNonblock(this->sock); |
70 | + TR_socketBind((TR_Socket)this->sock); | |
70 | 71 | |
71 | - this->sockSSL = TR_new(TR_Sock, this->logger, port+1); | |
72 | + this->sockSSL = TR_new(TR_TcpSocket, this->logger, "0.0.0.0", port+1, 0); | |
72 | 73 | TR_socketNonblock(this->sockSSL); |
74 | + TR_socketBind((TR_Socket)this->sockSSL); | |
73 | 75 | |
74 | 76 | SSL_library_init(); |
75 | 77 | OpenSSL_add_all_algorithms(); |
... | ... | @@ -88,9 +90,6 @@ serverCtor(void * _this, va_list * params) |
88 | 90 | CONFIGDIR "/taskrambler.pem", |
89 | 91 | SSL_FILETYPE_PEM); |
90 | 92 | |
91 | - TR_socketListen(this->sock, backlog); | |
92 | - TR_socketListen(this->sockSSL, backlog); | |
93 | - | |
94 | 93 | (this->fds)[0].fd = this->sock->handle; |
95 | 94 | (this->fds)[0].events = POLLIN; |
96 | 95 | (this->fds)[1].fd = this->sockSSL->handle; | ... | ... |
Please
register
or
login
to post a comment