RC4: Allocate 8 extra bytes for send buffer.
[paraslash.git] / udp_send.c
index 3f9059bb0b03f81c50ec2ef722e255effd41b1ce..e80670d0f3866dcde32114c0459a506b8cb78cff 100644 (file)
@@ -192,11 +192,13 @@ static void udp_shutdown_targets(void)
        size_t len = 0; /* STFU, gcc */
 
        list_for_each_entry_safe(ut, tmp, &targets, node) {
+               int ubuntu_glibc_headers_suck;
                if (ut->fd < 0)
                        continue;
                if (!buf)
                        len = vss_get_fec_eof_packet(&buf);
-               write(ut->fd, buf, len);
+               /* ignore return value, we're closing the target anyway. */
+               ubuntu_glibc_headers_suck = write(ut->fd, buf, len); /* STFU */
                udp_close_target(ut);
        }
 }
@@ -240,22 +242,24 @@ static int udp_send_fec(char *buf, size_t len, void *private_data)
        if (ret < 0)
                goto fail;
        ret = send_queued_chunks(ut->fd, ut->cq, 0);
+       if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED))
+               ret = 0;
        if (ret < 0)
                goto fail;
        if (!len)
                return 0;
        if (!ret) { /* still data left in the queue */
-               ret = cq_enqueue(ut->cq, buf, len);
-               if (ret < 0)
-                       goto fail;
+               ret = cq_force_enqueue(ut->cq, buf, len);
+               assert(ret >= 0);
        }
        ret = write_nonblock(ut->fd, buf, len, 0);
+       if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED))
+               ret = 0;
        if (ret < 0)
                goto fail;
        if (ret != len) {
-               ret = cq_enqueue(ut->cq, buf + ret, len - ret);
-               if (ret < 0)
-                       goto fail;
+               ret = cq_force_enqueue(ut->cq, buf + ret, len - ret);
+               assert(ret >= 0);
        }
        return 1;
 fail: