summaryrefslogtreecommitdiff
path: root/ot_mutex.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-26 20:03:22 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-10-26 20:03:22 +0100
commit2d6b6d4da1d9732b2b02989a4374d356ff840d1b (patch)
tree50ff9d2fba93934d1572706f10593aec0ea57e07 /ot_mutex.c
parentf2f5b0450d4b7269bafdfb1bd1788303f6d8ce7b (diff)
Replace libowfat's event waiter with our own abstraction
It's with a heavy heart that I remove libowfat as my event library from opentracker. libowfat is what taught opentracker to walk and then fly. The tracker was literally standing on the shoulder of giants when I started writing it in 2006. For its time, the event abstraction was unparalleled and it has held up for many years, and it served the bittorrent community greatly. https://erdgeist.org/gitweb/opentracker/commit/?id=ad472597c569568bad0526d116b601dfcb36638c Unfortunately, it is very likely that libowfat will not be maintained anymore for the foreseeable future, it is already not easy to get its source from upstream and opentracker started receiving bug reports that I can not reasonably answer or patch. Before the project gets more dependent on the limitations of libowfat's current state, I need to teach opentracker to stand on its own feet and fly by itself. I've learned a great deal in the process and have even more respect now for what libowfat pioneered. The path for opentracker is cleared now. Ground work has already been laid in the migration process to support multi threaded http processing while keeping the aggressive reduction of syscalls alive that made the libowfat+opentracker combo so scalable. Here be some dragons, though: Even though there is a unit test suite now, the event loop's rewrite has not been battle tested yet. So you might want to hold up for a bit before jumping on the solo band wagon. What awaits at the end will be a long overdue v1.0, which will be named in honour of Felix.
Diffstat (limited to 'ot_mutex.c')
-rw-r--r--ot_mutex.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ot_mutex.c b/ot_mutex.c
index 2a8cbf5..37d9962 100644
--- a/ot_mutex.c
+++ b/ot_mutex.c
@@ -8,11 +8,10 @@
8#include <pthread.h> 8#include <pthread.h>
9#include <stdio.h> 9#include <stdio.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <unistd.h>
11#include <string.h> 12#include <string.h>
12#include <sys/uio.h> 13#include <sys/uio.h>
13 14
14/* Libowfat */
15#include "io.h"
16 15
17/* Opentracker */ 16/* Opentracker */
18#include "ot_iovec.h" 17#include "ot_iovec.h"
@@ -193,7 +192,8 @@ int mutex_workqueue_pushresult(ot_taskid taskid, size_t iovec_entries, struct io
193 /* Release lock */ 192 /* Release lock */
194 pthread_mutex_unlock(&tasklist_mutex); 193 pthread_mutex_unlock(&tasklist_mutex);
195 194
196 io_trywrite(g_self_pipe[1], &byte, 1); 195 /* A full pipe has already done this nudge's job, so a failure is fine */
196 (void)!write(g_self_pipe[1], &byte, 1);
197 197
198 /* Indicate whether the worker has to throw away results */ 198 /* Indicate whether the worker has to throw away results */
199 return task ? 0 : -1; 199 return task ? 0 : -1;
@@ -221,7 +221,8 @@ int mutex_workqueue_pushchunked(ot_taskid taskid, struct iovec *iovec) {
221 /* Release lock */ 221 /* Release lock */
222 pthread_mutex_unlock(&tasklist_mutex); 222 pthread_mutex_unlock(&tasklist_mutex);
223 223
224 io_trywrite(g_self_pipe[1], &byte, 1); 224 /* A full pipe has already done this nudge's job, so a failure is fine */
225 (void)!write(g_self_pipe[1], &byte, 1);
225 226
226 /* Indicate whether the worker has to throw away results */ 227 /* Indicate whether the worker has to throw away results */
227 return task ? 0 : -1; 228 return task ? 0 : -1;