socket_wrapper: fix PCAP support broken by aaea68791cfea45c6fa69abc93ad6d0e832d0283
[ira/wip.git] / lib / socket_wrapper / socket_wrapper.c
index dc0124bdb7720572a040ecfe6ce4e1fa540a52f6..1e3927705b215ba85bccd05522f4c70540ca9c00 100644 (file)
@@ -901,7 +901,7 @@ static int swrap_get_pcap_fd(const char *fname)
 
                if (write(fd, &file_hdr, sizeof(file_hdr)) != sizeof(file_hdr)) {
                        close(fd);
-                       return -1;
+                       fd = -1;
                }
                return fd;
        }
@@ -1194,11 +1194,9 @@ static void swrap_dump_packet(struct socket_info *si,
        fd = swrap_get_pcap_fd(file_name);
        if (fd != -1) {
                if (write(fd, packet, packet_len) != packet_len) {
-                       close(fd);
                        free(packet);
                        return;
                }
-               close(fd);
        }
 
        free(packet);