summaryrefslogtreecommitdiff
path: root/ot_mutex.c
diff options
context:
space:
mode:
authorerdgeist <>2009-01-15 23:01:36 +0000
committererdgeist <>2009-01-15 23:01:36 +0000
commit66c906d5d3c100e5fe1e6f088bd1ea17c5831894 (patch)
tree33eb4f386d14327277689e66143d5e607b3eef98 /ot_mutex.c
parent4ced0484abae55546e04954b3dafad46f9db348a (diff)
Add comments, rename our struct http_data h to cookie, all clientsockets to sock, all size_t from socket_recvs to byte_count. Make signal handler set default handler for the second SIGINT
Diffstat (limited to 'ot_mutex.c')
-rw-r--r--ot_mutex.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ot_mutex.c b/ot_mutex.c
index 36de5ff..2ed5e81 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -113,7 +113,7 @@ size_t mutex_get_torrent_count( ) {
113struct ot_task { 113struct ot_task {
114 ot_taskid taskid; 114 ot_taskid taskid;
115 ot_tasktype tasktype; 115 ot_tasktype tasktype;
116 int64 socket; 116 int64 sock;
117 int iovec_entries; 117 int iovec_entries;
118 struct iovec *iovec; 118 struct iovec *iovec;
119 struct ot_task *next; 119 struct ot_task *next;
@@ -124,7 +124,7 @@ static struct ot_task *tasklist = NULL;
124static pthread_mutex_t tasklist_mutex; 124static pthread_mutex_t tasklist_mutex;
125static pthread_cond_t tasklist_being_filled; 125static pthread_cond_t tasklist_being_filled;
126 126
127int mutex_workqueue_pushtask( int64 socket, ot_tasktype tasktype ) { 127int mutex_workqueue_pushtask( int64 sock, ot_tasktype tasktype ) {
128 struct ot_task ** tmptask, * task; 128 struct ot_task ** tmptask, * task;
129 129
130 /* Want exclusive access to tasklist */ 130 /* Want exclusive access to tasklist */
@@ -148,7 +148,7 @@ int mutex_workqueue_pushtask( int64 socket, ot_tasktype tasktype ) {
148 148
149 task->taskid = 0; 149 task->taskid = 0;
150 task->tasktype = tasktype; 150 task->tasktype = tasktype;
151 task->socket = socket; 151 task->sock = sock;
152 task->iovec_entries = 0; 152 task->iovec_entries = 0;
153 task->iovec = NULL; 153 task->iovec = NULL;
154 task->next = 0; 154 task->next = 0;
@@ -162,7 +162,7 @@ int mutex_workqueue_pushtask( int64 socket, ot_tasktype tasktype ) {
162 return 0; 162 return 0;
163} 163}
164 164
165void mutex_workqueue_canceltask( int64 socket ) { 165void mutex_workqueue_canceltask( int64 sock ) {
166 struct ot_task ** task; 166 struct ot_task ** task;
167 167
168 /* Want exclusive access to tasklist */ 168 /* Want exclusive access to tasklist */
@@ -171,10 +171,10 @@ void mutex_workqueue_canceltask( int64 socket ) {
171 MTX_DBG( "canceltask locked.\n" ); 171 MTX_DBG( "canceltask locked.\n" );
172 172
173 task = &tasklist; 173 task = &tasklist;
174 while( *task && ( (*task)->socket != socket ) ) 174 while( *task && ( (*task)->sock != sock ) )
175 *task = (*task)->next; 175 *task = (*task)->next;
176 176
177 if( *task && ( (*task)->socket == socket ) ) { 177 if( *task && ( (*task)->sock == sock ) ) {
178 struct iovec *iovec = (*task)->iovec; 178 struct iovec *iovec = (*task)->iovec;
179 struct ot_task *ptask = *task; 179 struct ot_task *ptask = *task;
180 int i; 180 int i;
@@ -281,7 +281,7 @@ int mutex_workqueue_pushresult( ot_taskid taskid, int iovec_entries, struct iove
281 281
282int64 mutex_workqueue_popresult( int *iovec_entries, struct iovec ** iovec ) { 282int64 mutex_workqueue_popresult( int *iovec_entries, struct iovec ** iovec ) {
283 struct ot_task ** task; 283 struct ot_task ** task;
284 int64 socket = -1; 284 int64 sock = -1;
285 285
286 /* Want exclusive access to tasklist */ 286 /* Want exclusive access to tasklist */
287 MTX_DBG( "popresult locks.\n" ); 287 MTX_DBG( "popresult locks.\n" );
@@ -297,7 +297,7 @@ int64 mutex_workqueue_popresult( int *iovec_entries, struct iovec ** iovec ) {
297 297
298 *iovec_entries = (*task)->iovec_entries; 298 *iovec_entries = (*task)->iovec_entries;
299 *iovec = (*task)->iovec; 299 *iovec = (*task)->iovec;
300 socket = (*task)->socket; 300 sock = (*task)->sock;
301 301
302 *task = (*task)->next; 302 *task = (*task)->next;
303 free( ptask ); 303 free( ptask );
@@ -307,7 +307,7 @@ int64 mutex_workqueue_popresult( int *iovec_entries, struct iovec ** iovec ) {
307 MTX_DBG( "popresult unlocks.\n" ); 307 MTX_DBG( "popresult unlocks.\n" );
308 pthread_mutex_unlock( &tasklist_mutex ); 308 pthread_mutex_unlock( &tasklist_mutex );
309 MTX_DBG( "popresult unlocked.\n" ); 309 MTX_DBG( "popresult unlocked.\n" );
310 return socket; 310 return sock;
311} 311}
312 312
313void mutex_init( ) { 313void mutex_init( ) {