]> mj.ucw.cz Git - libucw.git/commitdiff
Main record-based I/O: allow freeing of recio from read handlers
authorMartin Mares <mj@ucw.cz>
Thu, 9 Jun 2011 14:51:15 +0000 (16:51 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 9 Jun 2011 14:51:15 +0000 (16:51 +0200)
ucw/main-rec.c

index 3c4c0678b73fa9f783f771e970c0aaf70ca0b2f6..2def9c8971f6ecf4cb36d7df77425e76dcc675a9 100644 (file)
@@ -131,6 +131,8 @@ restart: ;
   while (rio->read_running && (got = rio->read_handler(rio)))
     {
       DBG("RIO READ: Ate %u bytes", got);
+      if (got == ~0U)
+       return HOOK_IDLE;
       rio->read_rec_start += got;
       rio->read_avail -= got;
       rio->read_prev_avail = 0;
@@ -326,6 +328,12 @@ static uns rhand(struct main_rec_io *rio)
     {
       rio->read_rec_start[r-1] = 0;
       printf("Read <%s>\n", rio->read_rec_start);
+      if (rio->read_rec_start[0] == '!')
+       {
+         rec_io_del(rio);
+         main_shut_down();
+         return ~0U;
+       }
       rec_io_set_timeout(rio, 10000);
       rio->read_rec_start[r-1] = '\n';
       rec_io_write(rio, rio->read_rec_start, r);