mirror of
https://github.com/sigmasternchen/CFloor
synced 2025-03-15 20:28:56 +00:00
moved connection reset for persistent connections to new function
This commit is contained in:
parent
aa8b6a725c
commit
9ee99f589a
1 changed files with 29 additions and 25 deletions
|
@ -506,31 +506,7 @@ int sendHeader(int statusCode, struct headers* headers, struct request* request)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void resetPersistentConnection(struct connection* connection) {
|
||||||
* This thread calls the handler.
|
|
||||||
*/
|
|
||||||
void* responseThread(void* data) {
|
|
||||||
struct connection* connection = (struct connection*) data;
|
|
||||||
|
|
||||||
debug("networking: calling response handler");
|
|
||||||
|
|
||||||
connection->threads.handler.handler((struct request) {
|
|
||||||
.metaData = connection->metaData,
|
|
||||||
.headers = &(connection->headers),
|
|
||||||
.fd = connection->readfd,
|
|
||||||
.peer = connection->peer,
|
|
||||||
.userData = connection->threads.handler.data,
|
|
||||||
._private = connection
|
|
||||||
}, (struct response) {
|
|
||||||
.sendHeader = sendHeader
|
|
||||||
});
|
|
||||||
|
|
||||||
debug("networking: response handler returned");
|
|
||||||
|
|
||||||
// lock before isPersistent check in case the connection gets aborted
|
|
||||||
pthread_mutex_lock(&(connection->lock));
|
|
||||||
if (connection->isPersistent) {
|
|
||||||
|
|
||||||
pthread_t self = pthread_self();
|
pthread_t self = pthread_self();
|
||||||
|
|
||||||
// kill request thread so that the connection doesn't get killed
|
// kill request thread so that the connection doesn't get killed
|
||||||
|
@ -569,6 +545,34 @@ void* responseThread(void* data) {
|
||||||
connection->state = OPENED;
|
connection->state = OPENED;
|
||||||
updateTiming(connection, true);
|
updateTiming(connection, true);
|
||||||
connection->inUse--;
|
connection->inUse--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This thread calls the handler.
|
||||||
|
*/
|
||||||
|
void* responseThread(void* data) {
|
||||||
|
struct connection* connection = (struct connection*) data;
|
||||||
|
|
||||||
|
debug("networking: calling response handler");
|
||||||
|
|
||||||
|
connection->threads.handler.handler((struct request) {
|
||||||
|
.metaData = connection->metaData,
|
||||||
|
.headers = &(connection->headers),
|
||||||
|
.fd = connection->readfd,
|
||||||
|
.peer = connection->peer,
|
||||||
|
.userData = connection->threads.handler.data,
|
||||||
|
._private = connection
|
||||||
|
}, (struct response) {
|
||||||
|
.sendHeader = sendHeader
|
||||||
|
});
|
||||||
|
|
||||||
|
debug("networking: response handler returned");
|
||||||
|
|
||||||
|
// lock before isPersistent check in case the connection gets aborted
|
||||||
|
pthread_mutex_lock(&(connection->lock));
|
||||||
|
if (connection->isPersistent) {
|
||||||
|
resetPersistentConnection(connection);
|
||||||
|
// unlock after reset
|
||||||
pthread_mutex_unlock(&(connection->lock));
|
pthread_mutex_unlock(&(connection->lock));
|
||||||
} else {
|
} else {
|
||||||
// unlock before safeEndConnection
|
// unlock before safeEndConnection
|
||||||
|
|
Loading…
Reference in a new issue