diff options
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/opentracker.c b/opentracker.c index 560e9a1..342acf7 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -94,7 +94,7 @@ const char* http_header(struct http_data* r,const char* h) | |||
94 | 94 | ||
95 | void httpresponse(struct http_data* h,int64 s) | 95 | void httpresponse(struct http_data* h,int64 s) |
96 | { | 96 | { |
97 | char *c, *d, *data, *reply = NULL; | 97 | char *c, *data, *reply = NULL; |
98 | ot_peer peer; | 98 | ot_peer peer; |
99 | ot_torrent *torrent; | 99 | ot_torrent *torrent; |
100 | ot_hash *hash = NULL; | 100 | ot_hash *hash = NULL; |
@@ -113,10 +113,10 @@ e400: | |||
113 | } | 113 | } |
114 | 114 | ||
115 | c+=4; | 115 | c+=4; |
116 | for (d=c; *d!=' '&&*d!='\t'&&*d!='\n'&&*d!='\r'; ++d) ; | 116 | for (data=c; *data!=' '&&*data!='\t'&&*data!='\n'&&*data!='\r'; ++data) ; |
117 | 117 | ||
118 | if (*d!=' ') goto e400; | 118 | if (*data!=' ') goto e400; |
119 | *d=0; | 119 | *data=0; |
120 | if (c[0]!='/') goto e404; | 120 | if (c[0]!='/') goto e404; |
121 | while (*c=='/') ++c; | 121 | while (*c=='/') ++c; |
122 | 122 | ||
@@ -291,7 +291,21 @@ e404: | |||
291 | 291 | ||
292 | bailout: | 292 | bailout: |
293 | io_dontwantread(s); | 293 | io_dontwantread(s); |
294 | shutdown(s, SHUT_RD ); | ||
294 | io_wantwrite(s); | 295 | io_wantwrite(s); |
296 | |||
297 | reply_size=iob_send(s,&h->iob); | ||
298 | if (reply_size==-1) { | ||
299 | io_eagain(s); | ||
300 | } else | ||
301 | if ((reply_size<=0)||(h->iob.bytesleft==0)) | ||
302 | { | ||
303 | array_reset(&h->r); | ||
304 | iob_reset(&h->iob); | ||
305 | free(h); | ||
306 | shutdown(s, SHUT_RDWR); | ||
307 | io_close(s); | ||
308 | } | ||
295 | } | 309 | } |
296 | 310 | ||
297 | void graceful( int s ) { | 311 | void graceful( int s ) { |