Merge branch 'silc.1.1.branch' of silc repo
[runtime.git] / lib / silcutil / unix / silcunixsocketstream.c
index 86c8491a9e95fced746b6086aea981034fd96dbd..35b0ceedcde1d702dc1c37496b9fbaee9a54fc1d 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2007 Pekka Riikonen
+  Copyright (C) 1997 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -16,9 +16,8 @@
   GNU General Public License for more details.
 
 */
-/* $Id$ */
 
-#include "silc.h"
+#include "silcruntime.h"
 
 /************************ Static utility functions **************************/
 
@@ -106,8 +105,9 @@ int silc_socket_stream_read(SilcStream stream, unsigned char *buf,
   /* If QoS was applied, return the data that was pending. */
   if (sock->qos->applied && sock->qos->data_len) {
     memcpy(buf, qosbuf, sock->qos->data_len);
+    len = sock->qos->data_len;
     sock->qos->data_len = 0;
-    return sock->qos->data_len;
+    return len;
   }
 
   /* If we have active QoS data pending, return with no data */
@@ -116,7 +116,8 @@ int silc_socket_stream_read(SilcStream stream, unsigned char *buf,
     return -1;
   }
 
-  /* Read the data from the socket.  Never read more than the max limit. */
+  /* Read the data from the socket.  The qosbuf size is always the max
+     read limit size. */
   len = (buf_len < sock->qos->read_limit_bytes ? buf_len :
         sock->qos->read_limit_bytes);
   len = read(sock->sock, qosbuf, len);