Replaced ST_* enum prefix for stream status with IO_STREAM_*.

This commit is contained in:
George Kadianakis 2011-07-18 02:35:29 +02:00
parent a8f21f91cf
commit 14c5a24fe7
3 changed files with 16 additions and 16 deletions

View File

@ -3140,10 +3140,10 @@ tor_spawn_background(const char *const filename, int *stdout_read,
* fits your needs before using it.
*
* Returns:
* ST_CLOSED: If the stream is closed.
* ST_EAGAIN: If there is nothing to read and we should check back later.
* ST_TERM: If something is wrong with the stream.
* ST_OKAY: If everything went okay and we got a string in <b>buf_out</b>. */
* IO_STREAM_CLOSED: If the stream is closed.
* IO_STREAM_EAGAIN: If there is nothing to read and we should check back later.
* IO_STREAM_TERM: If something is wrong with the stream.
* IO_STREAM_OKAY: If everything went okay and we got a string in <b>buf_out</b>. */
enum stream_status
get_string_from_pipe(FILE *stream, char *buf_out, size_t count)
{
@ -3156,14 +3156,14 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count)
if (feof(stream)) {
/* Program has closed stream (probably it exited) */
/* TODO: check error */
return ST_CLOSED;
return IO_STREAM_CLOSED;
} else {
if (EAGAIN == errno) {
/* Nothing more to read, try again next time */
return ST_EAGAIN;
return IO_STREAM_EAGAIN;
} else {
/* There was a problem, abandon this child process */
return ST_TERM;
return IO_STREAM_TERM;
}
}
} else {
@ -3175,11 +3175,11 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count)
buf_out[len - 1] = '\0';
}
return ST_OKAY;
return IO_STREAM_OKAY;
}
/* We should never get here */
return ST_TERM;
return IO_STREAM_TERM;
}
/** Read from stream, and send lines to log at the specified log level.

View File

@ -281,10 +281,10 @@ ssize_t read_all(tor_socket_t fd, char *buf, size_t count, int isSocket);
/** Status of an I/O stream. */
enum stream_status {
ST_OKAY,
ST_EAGAIN,
ST_TERM,
ST_CLOSED
IO_STREAM_OKAY,
IO_STREAM_EAGAIN,
IO_STREAM_TERM,
IO_STREAM_CLOSED
};
enum stream_status get_string_from_pipe(FILE *stream, char *buf, size_t count);

View File

@ -163,14 +163,14 @@ configure_proxy(managed_proxy_t *mp)
r = get_string_from_pipe(mp->stdout, stdout_buf,
sizeof(stdout_buf) - 1);
if (r == ST_CLOSED || r == ST_TERM) {
if (r == IO_STREAM_CLOSED || r == IO_STREAM_TERM) {
log_warn(LD_GENERAL, "Managed proxy stream closed. "
"Most probably application stopped running");
mp->conf_state = PT_PROTO_BROKEN;
} else if (r == ST_EAGAIN) {
} else if (r == IO_STREAM_EAGAIN) {
return;
} else {
tor_assert(r == ST_OKAY);
tor_assert(r == IO_STREAM_OKAY);
handle_proxy_line(stdout_buf, mp);
}