Created
July 20, 2014 11:56
-
-
Save bassosimone/fffd3bf66f3b5fcd1f58 to your computer and use it in GitHub Desktop.
[PATCH] Use IghtEvbufer, IghtBuffereventSocket in IghtConnection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ext/http-parser b/src/ext/http-parser | |
--- a/src/ext/http-parser | |
+++ b/src/ext/http-parser | |
@@ -1 +1 @@ | |
-Subproject commit 8d9e5db981b623fffc93657abacdc80270cbee58 | |
+Subproject commit 8d9e5db981b623fffc93657abacdc80270cbee58-dirty | |
diff --git a/src/net/connection.cpp b/src/net/connection.cpp | |
index 4afbb53..2b20458 100644 | |
--- a/src/net/connection.cpp | |
+++ b/src/net/connection.cpp | |
@@ -29,9 +29,7 @@ | |
IghtConnection::IghtConnection(void) | |
{ | |
this->filedesc = IGHT_SOCKET_INVALID; | |
- this->bev = NULL; | |
this->protocol = NULL; | |
- this->readbuf = NULL; | |
this->closing = 0; | |
this->connecting = 0; | |
this->reading = 0; | |
@@ -49,14 +47,8 @@ IghtConnection::~IghtConnection(void) | |
if (this->filedesc != IGHT_SOCKET_INVALID) | |
(void) evutil_closesocket((evutil_socket_t) this->filedesc); | |
- if (this->bev != NULL) | |
- bufferevent_free(this->bev); | |
- | |
// protocol: should already be dead | |
- if (this->readbuf != NULL) | |
- evbuffer_free(this->readbuf); | |
- | |
// closing: nothing to be done | |
// connecting: nothing to be done | |
// reading: nothing to be done | |
@@ -171,7 +163,7 @@ IghtConnection::attach(IghtProtocol *proto, long long filenum) | |
// filedesc: only set on success | |
- self->bev = bufferevent_socket_new(evbase, (evutil_socket_t)filenum, | |
+ self->bev = IghtBuffereventSocket(evbase, (evutil_socket_t)filenum, | |
BEV_OPT_DEFER_CALLBACKS); | |
if (self->bev == NULL) { | |
delete self; | |
@@ -180,12 +172,6 @@ IghtConnection::attach(IghtProtocol *proto, long long filenum) | |
self->protocol = proto; | |
- self->readbuf = evbuffer_new(); | |
- if (self->readbuf == NULL) { | |
- delete self; | |
- return (NULL); | |
- } | |
- | |
// closing: nothing to be done | |
// connecting: nothing to be done | |
// reading: nothing to be done | |
@@ -266,7 +252,7 @@ IghtConnection::connect(IghtProtocol *proto, const char *family, | |
return (NULL); | |
} | |
- self->bev = bufferevent_socket_new(evbase, | |
+ self->bev = IghtBuffereventSocket(evbase, | |
(evutil_socket_t)self->filedesc, BEV_OPT_DEFER_CALLBACKS); | |
if (self->bev == NULL) { | |
delete self; | |
@@ -275,12 +261,6 @@ IghtConnection::connect(IghtProtocol *proto, const char *family, | |
self->protocol = proto; | |
- self->readbuf = evbuffer_new(); | |
- if (self->readbuf == NULL) { | |
- delete self; | |
- return (NULL); | |
- } | |
- | |
// closing: nothing to be done | |
self->connecting = 1; | |
@@ -614,7 +594,7 @@ IghtConnection::connect_hostname(IghtProtocol *proto, | |
// filedesc: nothing to be done | |
- self->bev = bufferevent_socket_new(evbase, | |
+ self->bev = IghtBuffereventSocket(evbase, | |
(evutil_socket_t) IGHT_SOCKET_INVALID, | |
BEV_OPT_DEFER_CALLBACKS); | |
if (self->bev == NULL) { | |
@@ -624,12 +604,6 @@ IghtConnection::connect_hostname(IghtProtocol *proto, | |
self->protocol = proto; | |
- self->readbuf = evbuffer_new(); | |
- if (self->readbuf == NULL) { | |
- delete self; | |
- return (NULL); | |
- } | |
- | |
// closing: nothing to be done | |
self->connecting = 1; | |
diff --git a/src/net/connection.h b/src/net/connection.h | |
index e727e73..a9f1f6c 100644 | |
--- a/src/net/connection.h | |
+++ b/src/net/connection.h | |
@@ -50,9 +50,9 @@ struct IghtProtocol; | |
struct IghtConnection { | |
private: | |
long long filedesc; | |
- bufferevent *bev; | |
+ IghtBuffereventSocket bev; | |
IghtProtocol *protocol; | |
- evbuffer *readbuf; | |
+ IghtEvbuffer readbuf; | |
unsigned int closing; | |
unsigned int connecting; | |
unsigned int reading; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment