summaryrefslogtreecommitdiff
path: root/ot_mutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_mutex.c')
-rw-r--r--ot_mutex.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ot_mutex.c b/ot_mutex.c
index 9aa476d..2a8cbf5 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -62,7 +62,7 @@ size_t mutex_get_torrent_count(void) { return g_torrent_count; }
62struct ot_task { 62struct ot_task {
63 ot_taskid taskid; 63 ot_taskid taskid;
64 ot_tasktype tasktype; 64 ot_tasktype tasktype;
65 int64 sock; 65 int64_t sock;
66 size_t iovec_entries; 66 size_t iovec_entries;
67 struct iovec *iovec; 67 struct iovec *iovec;
68 struct ot_task *next; 68 struct ot_task *next;
@@ -73,7 +73,7 @@ static struct ot_task *tasklist;
73static pthread_mutex_t tasklist_mutex; 73static pthread_mutex_t tasklist_mutex;
74static pthread_cond_t tasklist_being_filled; 74static pthread_cond_t tasklist_being_filled;
75 75
76int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) { 76int mutex_workqueue_pushtask(int64_t sock, ot_tasktype tasktype) {
77 struct ot_task **tmptask, *task; 77 struct ot_task **tmptask, *task;
78 78
79 task = malloc(sizeof(struct ot_task)); 79 task = malloc(sizeof(struct ot_task));
@@ -102,7 +102,7 @@ int mutex_workqueue_pushtask(int64 sock, ot_tasktype tasktype) {
102 return 0; 102 return 0;
103} 103}
104 104
105void mutex_workqueue_canceltask(int64 sock) { 105void mutex_workqueue_canceltask(int64_t sock) {
106 struct ot_task **task; 106 struct ot_task **task;
107 107
108 /* Want exclusive access to tasklist */ 108 /* Want exclusive access to tasklist */
@@ -114,9 +114,10 @@ void mutex_workqueue_canceltask(int64 sock) {
114 struct ot_task *ptask = *task; 114 struct ot_task *ptask = *task;
115 size_t i; 115 size_t i;
116 116
117 /* Free task's iovec */ 117 /* Free task's iovec, the buffers it points at and the vector itself */
118 for (i = 0; i < (*task)->iovec_entries; ++i) 118 for (i = 0; i < (*task)->iovec_entries; ++i)
119 free(iovec[i].iov_base); 119 free(iovec[i].iov_base);
120 free(iovec);
120 121
121 *task = (*task)->next; 122 *task = (*task)->next;
122 free(ptask); 123 free(ptask);
@@ -226,9 +227,9 @@ int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec) {
226 return task ? 0 : -1; 227 return task ? 0 : -1;
227} 228}
228 229
229int64 mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) { 230int64_t mutex_workqueue_popresult(size_t *iovec_entries, struct iovec **iovec, int *is_partial) {
230 struct ot_task **task; 231 struct ot_task **task;
231 int64 sock = -1; 232 int64_t sock = -1;
232 233
233 *is_partial = 0; 234 *is_partial = 0;
234 235