[systemd-commits] Branch 'sabridge-clean' - src/sabridge
David Strauss
straussd at kemper.freedesktop.org
Tue Oct 15 01:11:22 PDT 2013
src/sabridge/sabridge.c | 40 +++++++++++++++++-----------------------
1 file changed, 17 insertions(+), 23 deletions(-)
New commits:
commit cb773e70df28bcebb1133fd42fd0f7f0fa0e3081
Author: David Strauss <david at davidstrauss.net>
Date: Tue Oct 15 01:11:20 2013 -0700
More review fixes.
diff --git a/src/sabridge/sabridge.c b/src/sabridge/sabridge.c
index fbd069d..f7bdaef 100644
--- a/src/sabridge/sabridge.c
+++ b/src/sabridge/sabridge.c
@@ -92,12 +92,12 @@ static int transfer_data_cb(sd_event_source *s, int fd, uint32_t revents, void *
total_clients--;
free_connection(c->c_destination);
free_connection(c);
- goto finish;
+ return r;
}
else if (len < 0) {
log_error("Error %d in recv from fd=%d: %m", errno, fd);
r = -1;
- goto finish;
+ return r;
}
c->buffer_filled_len = len;
@@ -106,23 +106,23 @@ static int transfer_data_cb(sd_event_source *s, int fd, uint32_t revents, void *
r = send(c->c_destination->fd, &c->buffer, c->buffer_filled_len, 0);
if (r < 0 && errno != EWOULDBLOCK && errno != EAGAIN) {
log_error("Error %d in send to fd=%d: %m", errno, fd);
- goto finish;
+ return r;
}
else if (errno == EWOULDBLOCK || errno == EAGAIN) {
/* Switch to listening for a sendable state in destination. */
r = sd_event_source_set_enabled(c->w_recv, SD_EVENT_OFF);
if (r < 0) {
log_error("Error %d muting recv for fd=%d: %s", r, fd, strerror(-r));
- goto finish;
+ return r;
}
r = sd_event_source_set_enabled(c->c_destination->w_send, SD_EVENT_ON);
if (r < 0) {
log_error("Error %d unmuting send for fd=%d: %s", r, c->c_destination->fd, strerror(-r));
- goto finish;
+ return r;
}
log_debug("Done with recv for fd=%d. Waiting on send for fd=%d.", fd, c->c_destination->fd);
- goto finish;
+ return r;
}
log_debug("Done with recv for fd=%d and send for fd=%d.", fd, c->c_destination->fd);
}
@@ -135,27 +135,26 @@ static int transfer_data_cb(sd_event_source *s, int fd, uint32_t revents, void *
r = send(fd, &c->buffer, c->buffer_filled_len, 0);
if (r < 0) {
log_error("Error %d in send to fd=%d: %m", errno, fd);
- goto finish;
+ return r;
}
/* Switch to listening for a receivable state in destination. */
r = sd_event_source_set_enabled(c->w_send, SD_EVENT_OFF);
if (r < 0) {
log_error("Error %d muting send for fd=%d: %s", r, fd, strerror(-r));
- goto finish;
+ return r;
}
r = sd_event_source_set_enabled(c->c_destination->w_recv, SD_EVENT_ON);
if (r < 0) {
log_error("Error %d unmuting recv for fd=%d: %s", r, c->c_destination->fd, strerror(-r));
- goto finish;
+ return r;
}
log_debug("Done with send for fd=%d. Waiting on recv for fd=%d.", fd, c->c_destination->fd);
}
-finish:
- return r;
+ return r;
}
/* Once sending to the server is unblocked, set up the real watchers. */
@@ -238,26 +237,26 @@ static int get_server_connection_fd(const struct proxy *proxy) {
s = getaddrinfo(proxy->remote_host, proxy->remote_service, &hints, &result);
if (s != 0) {
log_error("getaddrinfo error (%d): %s", s, gai_strerror(s));
- goto finish;
+ return r;
}
if (result == NULL) {
log_error("getaddrinfo: no result");
- goto finish;
+ return r;
}
/* @TODO: Try connecting to all results instead of just the first. */
server_fd = socket(result->ai_family, result->ai_socktype | SOCK_NONBLOCK, result->ai_protocol);
if (server_fd < 0) {
log_error("Error %d creating socket: %m", errno);
- goto finish;
+ return r;
}
r = connect(server_fd, result->ai_addr, result->ai_addrlen);
/* Ignore EINPROGRESS errors because they're expected for a non-blocking socket. */
if (r < 0 && errno != EINPROGRESS) {
log_error("Error %d while connecting to socket %s:%s: %m", errno, proxy->remote_host, proxy->remote_service);
- goto finish;
+ return r;
}
}
else {
@@ -266,8 +265,7 @@ static int get_server_connection_fd(const struct proxy *proxy) {
server_fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (server_fd < 0) {
log_error("Error %d creating socket: %m", errno);
- r = -EBADFD;
- goto finish;
+ return -EBADFD;
}
remote.sun_family = AF_UNIX;
@@ -276,16 +274,12 @@ static int get_server_connection_fd(const struct proxy *proxy) {
r = connect(server_fd, (struct sockaddr *) &remote, len);
if (r < 0 && errno != EINPROGRESS) {
log_error("Error %d while connecting to Unix domain socket %s: %m", errno, proxy->remote_host);
- r = -EBADFD;
- goto finish;
+ return -EBADFD;
}
}
log_debug("Server connection is fd=%d", server_fd);
- r = server_fd;
-
-finish:
- return r;
+ return server_fd;
}
static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
More information about the systemd-commits
mailing list