libimobiledevice / libimobiledevice-glue

A library with common code used by libraries and tools around the libimobiledevice project
GNU Lesser General Public License v2.1
86 stars 69 forks source link

Content of `src/socket.c` in `libimobiledevice-glue-1.2.0.tar.bz2` doesn't match git tag #42

Closed 0x9fff00 closed 3 months ago

0x9fff00 commented 3 months ago

The file src/socket.c in the released libimobiledevice-glue-1.2.0.tar.bz2 tarball from https://github.com/libimobiledevice/libimobiledevice-glue/releases/tag/1.2.0 contains additional code that isn't in https://github.com/libimobiledevice/libimobiledevice-glue/blob/1.2.0/src/socket.c, see diff below:

diff --git a/src/socket.c b/src/socket.c
index 5276b1e..9bf60da 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -1159,6 +1159,23 @@ int socket_connect_addr(struct sockaddr* addr, uint16_t port)
                perror("Could not set receive buffer for socket");
        }

+       int val = 1;
+       if (setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepalive for socket");
+       }
+       val = 3;
+       if (setsockopt(sfd, IPPROTO_TCP, TCP_KEEPALIVE, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepidle for socket");
+       }
+       val = 3;
+       if (setsockopt(sfd, IPPROTO_TCP, TCP_KEEPINTVL, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepintvl for socket");
+       }
+       val = 3;
+       if (setsockopt(sfd, IPPROTO_TCP, TCP_KEEPCNT, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepcnt for socket");
+       }
+
        return sfd;
 }

@@ -1282,6 +1299,23 @@ int socket_connect(const char *addr, uint16_t port)
                perror("Could not set receive buffer for socket");
        }

+       int val = 1;
+       if (setsockopt(sfd, SOL_SOCKET, SO_KEEPALIVE, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepalive for socket");
+       }
+       val = 3;
+       if (setsockopt(sfd, IPPROTO_TCP, TCP_KEEPALIVE, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepidle for socket");
+       }
+       val = 3;
+       if (setsockopt(sfd, IPPROTO_TCP, TCP_KEEPINTVL, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepintvl for socket");
+       }
+       val = 3;
+       if (setsockopt(sfd, IPPROTO_TCP, TCP_KEEPCNT, (void*)&val, sizeof(int)) == -1) {
+               perror("Could not set keepcnt for socket");
+       }
+
        return sfd;
 }
nikias commented 3 months ago

That was an experiment and I published this by mistake. I updated the release tar.bz2 now.

ryandesign commented 3 months ago

In the future, please do not ever replace release tarballs like this. Once a tarball is released, it should never change. If you need to make changes, release a new version. Otherwise, among other problems, those who already had the "bad" version of 1.2.0 would never know that a new one was available.

nikias commented 3 months ago

I know. Hopefully not going to happen again.