From 0bf762ee3898a853066adecf1cc85a71b077591d Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 11 Apr 2004 17:35:09 +0000 Subject: [PATCH] Attempted sync fixes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@538 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/connection.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/connection.cpp b/src/connection.cpp index b1ed34455..574139e1a 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -160,7 +160,7 @@ bool connection::SendPacket(char *message, char* host, int port, long ourkey) int res = select(65535, &sfd, NULL, NULL, &tval); cycles++; } - while ((recvfrom(fd,&p2,sizeof(p2),0,(sockaddr*)&host_address,&host_address_size)<0) && (cycles < 10)); + while ((recvfrom(fd,&p2,sizeof(p2),MSG_PEEK,(sockaddr*)&host_address,&host_address_size)<0) && (cycles < 10)); if (cycles >= 10) { @@ -168,6 +168,13 @@ bool connection::SendPacket(char *message, char* host, int port, long ourkey) } else { + if (p2.type != PT_ACK_ONLY) + { + log(DEFAULT,"ERROR! connection::SendPacket() received a data response and was expecting a syn!!!"); + this->state = STATE_CLEAR; + return true; + } + if (p2.id != p.id) { log(DEFAULT,"ERROR! connection::SendPacket() received an ack for a packet it didnt send!"); @@ -284,6 +291,7 @@ bool connection::RecvPacket(char *message, char* host, int &prt, long &theirkey) host_address.sin_family=AF_INET; host_address_size=sizeof(host_address); + //int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); if (recvfrom(fd,&p,sizeof(p),0,(sockaddr*)&host_address,&host_address_size)<0) { return false; -- 2.39.2