Commit e73c8d959dbdfd2708986eb5d60410bc7fd6f028

Authored by Georg Hopp
1 parent 4f95d8ce

get rid of some unneccessary system calls...one socket and one close

@@ -122,10 +122,6 @@ httpWriterWrite(void * _this, int fd) @@ -122,10 +122,6 @@ httpWriterWrite(void * _this, int fd)
122 break; 122 break;
123 123
124 case HTTP_WRITER_DONE: 124 case HTTP_WRITER_DONE:
125 - if (HTTP_MESSAGE_PIPED == this->current->type) {  
126 - close(this->current->handle);  
127 - }  
128 -  
129 this->state = HTTP_WRITER_GET; 125 this->state = HTTP_WRITER_GET;
130 126
131 memmove(respq->msgs, 127 memmove(respq->msgs,
@@ -35,9 +35,17 @@ socketCtor(void * _this, va_list * params) @@ -35,9 +35,17 @@ socketCtor(void * _this, va_list * params)
35 { 35 {
36 Sock this = _this; 36 Sock this = _this;
37 int reUse = 1; //! \todo make this configurable 37 int reUse = 1; //! \todo make this configurable
  38 + int port;
38 39
39 this->log = va_arg(* params, Logger); 40 this->log = va_arg(* params, Logger);
40 - this->port = va_arg(* params, int); 41 + port = va_arg(* params, int);
  42 +
  43 + //! if port is -1 do not initialize the socket. (Used with accept)
  44 + if (-1 == port) {
  45 + return 0;
  46 + } else {
  47 + this->port = port;
  48 + }
41 49
42 //! Create socket for incoming connections 50 //! Create socket for incoming connections
43 if (-1 == (this->handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))) { 51 if (-1 == (this->handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))) {
@@ -43,11 +43,7 @@ socketAccept(Sock this, char (*remoteAddr)[16]) @@ -43,11 +43,7 @@ socketAccept(Sock this, char (*remoteAddr)[16])
43 * the data structure without creation of a socket at all. 43 * the data structure without creation of a socket at all.
44 * For now i simply close the socket here.... :D 44 * For now i simply close the socket here.... :D
45 */ 45 */
46 - sock = new(Sock, this->log, this->port);  
47 - close(sock->handle);  
48 - /**  
49 - * \todo change port to remote port on success  
50 - */ 46 + sock = new(Sock, this->log, -1);
51 47
52 // Wait for a client to connect 48 // Wait for a client to connect
53 sock->handle = accept(this->handle, (struct sockaddr *) &(sock->addr), &len); 49 sock->handle = accept(this->handle, (struct sockaddr *) &(sock->addr), &len);
Please register or login to post a comment