summaryrefslogtreecommitdiff
path: root/proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'proxy.c')
-rw-r--r--proxy.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/proxy.c b/proxy.c
index a870c63..63b4c4f 100644
--- a/proxy.c
+++ b/proxy.c
@@ -16,9 +16,9 @@
16 16
17/* Libowfat */ 17/* Libowfat */
18#include "io.h" 18#include "io.h"
19#include "iob.h"
20 19
21/* Opentracker */ 20/* Opentracker */
21#include "ot_batch.h"
22#include "ot_ip.h" 22#include "ot_ip.h"
23#include "ot_mutex.h" 23#include "ot_mutex.h"
24#include "ot_random.h" 24#include "ot_random.h"
@@ -72,7 +72,7 @@ static void *livesync_worker(void *args);
72static void *streamsync_worker(void *args); 72static void *streamsync_worker(void *args);
73static void livesync_proxytell(uint8_t prefix, uint8_t *info_hash, uint8_t *peer); 73static void livesync_proxytell(uint8_t prefix, uint8_t *info_hash, uint8_t *peer);
74 74
75void exerr(char *message) { 75void exerr(const char *message) {
76 fprintf(stderr, "%s\n", message); 76 fprintf(stderr, "%s\n", message);
77 exit(111); 77 exit(111);
78} 78}
@@ -228,7 +228,7 @@ typedef struct {
228 size_t indata_length; /* Length of unprocessed data */ 228 size_t indata_length; /* Length of unprocessed data */
229 uint32_t tracker_id; /* How the other end greeted */ 229 uint32_t tracker_id; /* How the other end greeted */
230 int64_t fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */ 230 int64_t fd; /* A file handle, if connected, <= 0 is disconnected (0 initially, -1 else) */
231 io_batch outdata; /* The iobatch containing our sync data */ 231 ot_batch outdata; /* The batch containing our sync data */
232 232
233 size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */ 233 size_t packet_tcount; /* Number of unprocessed torrents in packet we currently receive */
234 uint8_t packet_tprefix; /* Prefix byte for all torrents in current packet */ 234 uint8_t packet_tprefix; /* Prefix byte for all torrents in current packet */
@@ -243,7 +243,7 @@ void reset_info_block(proxy_peer *peer) {
243 peer->tracker_id = 0; 243 peer->tracker_id = 0;
244 peer->fd = -1; 244 peer->fd = -1;
245 peer->packet_tcount = 0; 245 peer->packet_tcount = 0;
246 iob_reset(&peer->outdata); 246 batch_reset(&peer->outdata);
247 PROXYPEER_SETDISCONNECTED(peer->state); 247 PROXYPEER_SETDISCONNECTED(peer->state);
248} 248}
249 249
@@ -424,11 +424,11 @@ static void handle_write(int64_t peersocket) {
424 } 424 }
425 break; 425 break;
426 case FLAG_CONNECTED: 426 case FLAG_CONNECTED:
427 switch (iob_send(peersocket, &peer->outdata)) { 427 switch (batch_send(peersocket, &peer->outdata)) {
428 case 0: /* all data sent */ 428 case BATCH_DONE:
429 io_dontwantwrite(peersocket); 429 io_dontwantwrite(peersocket);
430 break; 430 break;
431 case -3: /* an error occured */ 431 case BATCH_FAILED:
432 io_close(peersocket); 432 io_close(peersocket);
433 reset_info_block(peer); 433 reset_info_block(peer);
434 break; 434 break;
@@ -728,7 +728,7 @@ static void *streamsync_worker(void *args) {
728 void *tmp = malloc(mem); 728 void *tmp = malloc(mem);
729 if (tmp) { 729 if (tmp) {
730 memcpy(tmp, ptr, mem); 730 memcpy(tmp, ptr, mem);
731 iob_addbuf_free(&g_connections[i].outdata, tmp, mem); 731 batch_add(&g_connections[i].outdata, tmp, mem);
732 io_wantwrite(g_connections[i].fd); 732 io_wantwrite(g_connections[i].fd);
733 } 733 }
734 } 734 }