diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-11-08 22:56:04 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-11-08 22:56:04 +0000 |
commit | 53ef4c2babc3d4bf8df16ba6bbd596d0b9a8240b (patch) | |
tree | 286476b1c81ce35d95e0cedce4dee1a728bfa5fb /status.c | |
parent | 5116aaa51a6059904a6b8ae75bffa77c95ceb41a (diff) | |
download | rtmux-53ef4c2babc3d4bf8df16ba6bbd596d0b9a8240b.tar.gz rtmux-53ef4c2babc3d4bf8df16ba6bbd596d0b9a8240b.tar.bz2 rtmux-53ef4c2babc3d4bf8df16ba6bbd596d0b9a8240b.zip |
Sync OpenBSD patchset 493:
Switch jobs over to use a bufferevent.
Diffstat (limited to 'status.c')
-rw-r--r-- | status.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.125 2009-11-04 23:12:32 tcunha Exp $ */ +/* $Id: status.c,v 1.126 2009-11-08 22:56:04 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -486,23 +486,26 @@ status_job(struct client *c, char **iptr) void status_job_callback(struct job *job) { - char *buf; + char *line, *buf; size_t len; - len = BUFFER_USED(job->out); - buf = xmalloc(len + 1); - if (len != 0) - buffer_read(job->out, buf, len); - buf[len] = '\0'; - buf[strcspn(buf, "\n")] = '\0'; + buf = NULL; + if ((line = evbuffer_readline(job->event->input)) == NULL) { + len = EVBUFFER_LENGTH(job->event->input); + buf = xmalloc(len + 1); + if (len != 0) + memcpy(buf, EVBUFFER_DATA(job->event->input), len); + buf[len] = '\0'; + } if (job->data != NULL) xfree(job->data); else server_redraw_client(job->client); - job->data = xstrdup(buf); + job->data = xstrdup(line); - xfree(buf); + if (buf != NULL) + xfree(buf); } size_t |