ry / ebb fork watch download tarball
public this repo is viewable by everyone
Description: web server
Homepage: http://ebb.rubyforge.org
Clone URL: git://github.com/ry/ebb.git
close client connections instead of killing server
Ryan Dahl (author)
2 months ago
commit  c8641291900ff5ab9e2a027ffb73213f5440b58b
tree    782ffc8eb10b1ff6660b2af1b69cd07c44c1d62a
parent  4780e2c81b44bf1b4f96f2ce064e6416024888cc
...
580
581
582
 
 
583
584
585
...
591
592
593
 
 
594
595
596
...
602
603
604
 
 
605
606
607
...
612
613
614
615
 
 
616
617
618
...
641
642
643
644
 
 
 
645
646
647
...
580
581
582
583
584
585
586
587
...
593
594
595
596
597
598
599
600
...
606
607
608
609
610
611
612
613
...
618
619
620
 
621
622
623
624
625
...
648
649
650
 
651
652
653
654
655
656
0
@@ -580,6 +580,8 @@ static void on_client_writable(struct ev_loop *loop, ev_io *watcher, int revents
0
 
0
 void ebb_client_write_status(ebb_client *client, int status, const char *human_status)
0
 {
0
+ if(!client->open)
0
+ return;
0
   assert(client->status_written == FALSE);
0
   g_string_append_printf( client->response_buffer
0
                         , "HTTP/1.1 %d %s\r\n"
0
@@ -591,6 +593,8 @@ void ebb_client_write_status(ebb_client *client, int status, const char *human_s
0
 
0
 void ebb_client_write_header(ebb_client *client, const char *field, const char *value)
0
 {
0
+ if(!client->open)
0
+ return;
0
   assert(client->status_written == TRUE);
0
   assert(client->headers_written == FALSE);
0
   g_string_append_printf( client->response_buffer
0
@@ -602,6 +606,8 @@ void ebb_client_write_header(ebb_client *client, const char *field, const char *
0
 
0
 void ebb_client_write(ebb_client *client, const char *data, int length)
0
 {
0
+ if(!client->open)
0
+ return;
0
   g_string_append_len(client->response_buffer, data, length);
0
   if(client->began_transmission) {
0
     /* restart the watcher if we're streaming */
0
@@ -612,7 +618,8 @@ void ebb_client_write(ebb_client *client, const char *data, int length)
0
 
0
 void ebb_client_begin_transmission(ebb_client *client)
0
 {
0
- assert(client->open);
0
+ if(!client->open)
0
+ return;
0
   assert(FALSE == ev_is_active(&client->write_watcher));
0
   
0
   /* assure the socket is still in non-blocking mode */
0
@@ -641,7 +648,9 @@ int ebb_client_read(ebb_client *client, char *buffer, int length)
0
 {
0
   size_t read;
0
   
0
- assert(client->open);
0
+ if(!client->open) {
0
+ return -1;
0
+ }
0
   assert(client_finished_parsing);
0
   
0
   if(client->upload_file) {

Comments

    No one has commented yet.