commit - 63bfde6efd083ce03a42abf45fb70cc685906368
commit + 520dc23bbf6da080a16df5b633445d3d625def64
blob - fc189ec58de815feecb3ddd1b48afa777e3270fe
blob + 6e6ae09721ee923cf1a1ccdf2f923c827ddf6515
--- gotd/libexec/got-notify-http/got-notify-http.c
+++ gotd/libexec/got-notify-http/got-notify-http.c
if (ret == 0 || timeout.tv_sec <= 0)
fatalx("timeout");
- if (bio.wbuf.len > 0 && (pfd.revents & POLLOUT)) {
+ if (bio.wbuf.len > 0) {
if (bufio_write(&bio) == -1 && errno != EAGAIN)
fatalx("bufio_write: %s", bufio_io_err(&bio));
}
- if (pfd.revents & POLLIN) {
- r = bufio_read(&bio);
- if (r == -1 && errno != EAGAIN)
- fatalx("bufio_read: %s", bufio_io_err(&bio));
- if (r == 0)
- fatalx("unexpected EOF");
- for (;;) {
- line = buf_getdelim(&bio.rbuf, "\r\n", &len);
- if (line == NULL)
- break;
- if (response_code && *line == '\0') {
- /*
- * end of headers, don't bother
- * reading the body, if there is.
- */
- done = 1;
- break;
- }
- if (response_code) {
- buf_drain(&bio.rbuf, len);
- continue;
- }
- spc = strchr(line, ' ');
- if (spc == NULL)
- fatalx("bad HTTP response from server");
- *spc++ = '\0';
- if (strcasecmp(line, "HTTP/1.1") != 0)
- log_warnx("unexpected protocol: %s",
- line);
- line = spc;
-
- spc = strchr(line, ' ');
- if (spc == NULL)
- fatalx("bad HTTP response from server");
- *spc++ = '\0';
-
- response_code = strtonum(line, 100, 599,
- &errstr);
- if (errstr != NULL)
- log_warnx("response code is %s: %s",
- errstr, line);
+ r = bufio_read(&bio);
+ if (r == -1 && errno != EAGAIN)
+ fatalx("bufio_read: %s", bufio_io_err(&bio));
+ if (r == 0)
+ fatalx("unexpected EOF");
+ for (;;) {
+ line = buf_getdelim(&bio.rbuf, "\r\n", &len);
+ if (line == NULL)
+ break;
+ if (response_code && *line == '\0') {
+ /*
+ * end of headers, don't bother
+ * reading the body, if there is.
+ */
+ done = 1;
+ break;
+ }
+ if (response_code) {
buf_drain(&bio.rbuf, len);
+ continue;
}
- if (done)
- break;
+ spc = strchr(line, ' ');
+ if (spc == NULL)
+ fatalx("bad HTTP response from server");
+ *spc++ = '\0';
+ if (strcasecmp(line, "HTTP/1.1") != 0)
+ log_warnx("unexpected protocol: %s", line);
+ line = spc;
+
+ spc = strchr(line, ' ');
+ if (spc == NULL)
+ fatalx("bad HTTP response from server");
+ *spc++ = '\0';
+
+ response_code = strtonum(line, 100, 599,
+ &errstr);
+ if (errstr != NULL)
+ log_warnx("response code is %s: %s",
+ errstr, line);
+
+ buf_drain(&bio.rbuf, len);
}
+ if (done)
+ break;
if (!feof(tmpfp) && bio.wbuf.len < sizeof(buf)) {
len = fread(buf, 1, sizeof(buf), tmpfp);