Coding style change
This commit is contained in:
+11
-11
@@ -26,15 +26,15 @@ void in_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
|
||||
size_t left = BUFLEN - copy_ctx->w_idx;
|
||||
ssize_t rc;
|
||||
left /= 2;
|
||||
if(left == 0)
|
||||
if (left == 0)
|
||||
left++;
|
||||
|
||||
|
||||
rc = read(fd->fd, ©_ctx->buffer[copy_ctx->w_idx], left);
|
||||
if(rc <= 0) {
|
||||
if(rc == -1 && errno == EAGAIN) {
|
||||
if (rc <= 0) {
|
||||
if (rc == -1 && errno == EAGAIN) {
|
||||
return;
|
||||
} else if(rc == -1) {
|
||||
} else if (rc == -1) {
|
||||
perror("read");
|
||||
}
|
||||
iomux_unregister_fd(mux, fd);
|
||||
@@ -43,13 +43,13 @@ void in_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
|
||||
|
||||
copy_ctx->w_idx += rc;
|
||||
|
||||
if(!copy_ctx->out_running) {
|
||||
if (!copy_ctx->out_running) {
|
||||
copy_ctx->out.what = MUX_EV_WRITE;
|
||||
iomux_register_fd(mux, ©_ctx->out);
|
||||
copy_ctx->out_running = 1;
|
||||
}
|
||||
|
||||
if(copy_ctx->w_idx == BUFLEN) {
|
||||
if (copy_ctx->w_idx == BUFLEN) {
|
||||
iomux_unregister_fd(mux, fd);
|
||||
}
|
||||
}
|
||||
@@ -61,8 +61,8 @@ void out_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
|
||||
size_t len = copy_ctx->w_idx - copy_ctx->r_idx;
|
||||
|
||||
rc = write(1, ©_ctx->buffer[copy_ctx->r_idx], len);
|
||||
if(rc <= 0) {
|
||||
if(rc == -1 && errno == EAGAIN) {
|
||||
if (rc <= 0) {
|
||||
if (rc == -1 && errno == EAGAIN) {
|
||||
return;
|
||||
} else {
|
||||
perror("write");
|
||||
@@ -72,10 +72,10 @@ void out_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
|
||||
copy_ctx->out_running = 0;
|
||||
} else {
|
||||
copy_ctx->r_idx += rc;
|
||||
if(copy_ctx->r_idx == copy_ctx->w_idx) {
|
||||
if (copy_ctx->r_idx == copy_ctx->w_idx) {
|
||||
iomux_unregister_fd(mux, fd);
|
||||
copy_ctx->out_running = 0;
|
||||
if(copy_ctx->w_idx == BUFLEN) {
|
||||
if (copy_ctx->w_idx == BUFLEN) {
|
||||
copy_ctx->w_idx = 0;
|
||||
copy_ctx->r_idx = 0;
|
||||
iomux_register_fd(mux, ©_ctx->in);
|
||||
@@ -88,7 +88,7 @@ void out_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
|
||||
int set_nonblocking(int fd)
|
||||
{
|
||||
int flags = fcntl(fd,F_GETFL,NULL);
|
||||
if(flags < 0 ) {
|
||||
if (flags < 0 ) {
|
||||
return flags;
|
||||
}
|
||||
return fcntl(fd,F_SETFL,flags | O_NONBLOCK);
|
||||
|
||||
Reference in New Issue
Block a user