Przeglądaj źródła

Workaround for Solaris libc

The Solaris libc has some issues with alternating input and output
on sockets passed to fdopen(). Apparently there is a shared buffer
which has to be emptied, either by fseek() or fflush(), whenever
the direction of the data flow changes.
tags/1.2
Timo Röhling 10 lat temu
rodzic
commit
859796b126
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4
    0
      postsrsd.c

+ 4
- 0
postsrsd.c Wyświetl plik

@@ -459,21 +459,25 @@ int main (int argc, char **argv)
459 459
           if (poll(&fds[2], 1, timeout * 1000) <= 0) return EXIT_FAILURE;
460 460
           line = fgets(linebuf, sizeof(linebuf), fp);
461 461
           while (line) {
462
+            fseek (fp, 0, SEEK_CUR); /* Workaround for Solaris */
462 463
             char* token;
463 464
             token = strtok(line, " \r\n");
464 465
             if (token == NULL || strcmp(token, "get") != 0) {
465 466
               fprintf (fp, "500 Invalid request\n");
467
+              fflush (fp);
466 468
               return EXIT_FAILURE;
467 469
             }
468 470
             token = strtok(NULL, "\r\n");
469 471
             if (!token) {
470 472
               fprintf (fp, "500 Invalid request\n");
473
+              fflush (fp);
471 474
               return EXIT_FAILURE;
472 475
             }
473 476
             key = url_decode(keybuf, sizeof(keybuf), token);
474 477
             if (!key) break;
475 478
             handler[i](srs, fp, key, domain, excludes);
476 479
             if (poll(&fds[2], 1, timeout * 1000) <= 0) break;
480
+            fflush (fp);
477 481
             line = fgets(linebuf, sizeof(linebuf), fp);
478 482
           }
479 483
           fclose (fp);

Ładowanie…
Anuluj
Zapisz