kill duplicate write_ok()
[paraslash.git] / dccp_send.c
index 5478c1d..c7805f7 100644 (file)
@@ -122,7 +122,12 @@ static void dccp_send(__unused struct audio_format *af,
                return;
 
        list_for_each_entry_safe(dc, tmp, &clients, node) {
-               if (!_write_ok(dc->fd))
+               ret = write_ok(dc->fd);
+               if (ret < 0) {
+                       dccp_shutdown_client(dc);
+                       continue;
+               }
+               if (!ret)
                        continue;
                if (!dc->header_sent && af->get_header_info && current_chunk) {
                        header_buf = af->get_header_info(&header_len);
@@ -130,10 +135,19 @@ static void dccp_send(__unused struct audio_format *af,
                                continue; /* header not yet available */
                        ret = write(dc->fd, header_buf, header_len);
                        if (ret != header_len) {
+                               int err = errno;
+                               PARA_ERROR_LOG("header write: %d/%d (%s)\n",
+                                       ret, header_len, ret < 0?
+                                       strerror(err) : "");
+                               dccp_shutdown_client(dc);
+                               continue;
+                       }
+                       ret = write_ok(dc->fd);
+                       if (ret < 0) {
                                dccp_shutdown_client(dc);
                                continue;
                        }
-                       if (!_write_ok(dc->fd))
+                       if (!ret)
                                continue;
                }
 //             PARA_DEBUG_LOG("writing %d bytes to fd %d\n", len, dc->fd);