]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Attempted sync fixes
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 11 Apr 2004 17:35:09 +0000 (17:35 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 11 Apr 2004 17:35:09 +0000 (17:35 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@538 e03df62e-2008-0410-955e-edbf42e46eb7

src/connection.cpp

index b1ed3445591ec8f65b768d0b569cd3fe89ac459e..574139e1a2e8412976e135ac6f92e384784410ef 100644 (file)
@@ -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;