X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=examples%2Fustream-example.c;h=88c7381040c469af74bb922b0b7ede14f9be99e0;hp=00c71222ac102f9773d56863f8cb7014483c5d0a;hb=cb6c1718e711db77f7b6a06c8bc51fe392509bbc;hpb=d3b328005573de83646bd3bc156ec82859c0441c;ds=sidebyside diff --git a/examples/ustream-example.c b/examples/ustream-example.c index 00c7122..88c7381 100644 --- a/examples/ustream-example.c +++ b/examples/ustream-example.c @@ -23,7 +23,7 @@ struct client { static void client_read_cb(struct ustream *s, int bytes) { - struct client *cl = container_of(s, struct client, s); + struct client *cl = container_of(s, struct client, s.stream); struct ustream_buf *buf = s->r.head; char *newline, *str; @@ -42,7 +42,7 @@ static void client_read_cb(struct ustream *s, int bytes) cl->ctr += newline + 1 - str; } while(1); - if (s->w.data_bytes > 256 && ustream_read_blocked(s)) { + if (s->w.data_bytes > 256 && !ustream_read_blocked(s)) { fprintf(stderr, "Block read, bytes: %d\n", s->w.data_bytes); ustream_set_read_blocked(s, true); } @@ -50,7 +50,7 @@ static void client_read_cb(struct ustream *s, int bytes) static void client_close(struct ustream *s) { - struct client *cl = container_of(s, struct client, s); + struct client *cl = container_of(s, struct client, s.stream); fprintf(stderr, "Connection closed\n"); ustream_free(s); @@ -70,7 +70,7 @@ static void client_notify_write(struct ustream *s, int bytes) static void client_notify_state(struct ustream *s) { - struct client *cl = container_of(s, struct client, s); + struct client *cl = container_of(s, struct client, s.stream); if (!s->eof) return;