silc_compare_timeval returns < 0, 0, > 0 instead of TRUE/FALSE.
[silc.git] / lib / silcutil / unix / silcunixsocketstream.c
index e68bef544e48efa366646094b93b4a2fe35227e5..f3107f39c36a1044401de229ea04a69de7fe01c7 100644 (file)
@@ -80,6 +80,8 @@ int silc_socket_stream_read(SilcStream stream, unsigned char *buf,
       if (errno == EAGAIN || errno == EINTR) {
        SILC_LOG_DEBUG(("Could not read immediately, will do it later"));
        silc_schedule_set_listen_fd(sock->schedule, sock->sock,
+                                   silc_schedule_get_fd_events(sock->schedule,
+                                                               sock->sock) |
                                    SILC_TASK_READ, FALSE);
        return -1;
       }
@@ -122,6 +124,8 @@ int silc_socket_stream_read(SilcStream stream, unsigned char *buf,
     if (errno == EAGAIN || errno == EINTR) {
       SILC_LOG_DEBUG(("Could not read immediately, will do it later"));
       silc_schedule_set_listen_fd(sock->schedule, sock->sock,
+                                 silc_schedule_get_fd_events(sock->schedule,
+                                                             sock->sock) |
                                  SILC_TASK_READ, FALSE);
       return -1;
     }
@@ -146,7 +150,7 @@ int silc_socket_stream_read(SilcStream stream, unsigned char *buf,
   /* If we have passed the rate time limit, set our new time limit,
      and zero the rate limit.  This limits reads per second. */
   silc_gettimeofday(&curtime);
-  if (!silc_compare_timeval(&curtime, &sock->qos->next_limit)) {
+  if (silc_compare_timeval(&curtime, &sock->qos->next_limit) > 0) {
     curtime.tv_sec++;
     sock->qos->next_limit = curtime;
     sock->qos->cur_rate = 0;
@@ -245,7 +249,7 @@ SilcBool silc_socket_get_error(SilcStream sock, char *error,
   memcpy(error, err, strlen(err));
   return TRUE;
 }
-#endif /* 0 */
+#endif
 
 /* Closes socket */