use libm with cyassl
[project/ustream-ssl.git] / ustream-example.c
index 01e3aab2c0c48d22da0ec7d0b320f614959f0bb2..ab9f6f7537110237ecb4da981ad6cc22c8c1410e 100644 (file)
@@ -1,3 +1,21 @@
+/*
+ * ustream-ssl - library for SSL over ustream
+ *
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
 #include <sys/socket.h>
 #include <netinet/in.h>
 
@@ -5,6 +23,7 @@
 #include <getopt.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include <libubox/ustream.h>
 #include <libubox/uloop.h>
@@ -75,7 +94,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);
        }