Imported Upstream version 2.4.5
[debian/amanda] / common-src / protocol.c
index 0e464efb9219d61bd5a7ac052be17cab6203cb8b..e7fe14224f699695c926614fdb5e4d8a3d7666e4 100644 (file)
@@ -24,7 +24,7 @@
  * file named AUTHORS, in the root directory of this distribution.
  */
 /*
- * $Id: protocol.c,v 1.27.2.1.6.3 2004/04/14 13:24:35 martinea Exp $
+ * $Id: protocol.c,v 1.27.2.1.6.2.2.2 2004/04/14 13:24:17 martinea Exp $
  *
  * implements amanda protocol
  */
@@ -140,6 +140,7 @@ pktype_t s;
     case P_BOGUS: return "P_BOGUS";
     case P_REQ: return "P_REQ";
     case P_REP: return "P_REP";
+    case P_PREP: return "P_PREP";
     case P_ACK: return "P_ACK";
     case P_NAK: return "P_NAK";
     default:
@@ -510,6 +511,7 @@ pkt_t *pkt;
 
     if(strcmp(typestr, "REQ") == 0) pkt->type = P_REQ;
     else if(strcmp(typestr, "REP") == 0) pkt->type = P_REP;
+    else if(strcmp(typestr, "PREP") == 0) pkt->type = P_PREP;
     else if(strcmp(typestr, "ACK") == 0) pkt->type = P_ACK;
     else if(strcmp(typestr, "NAK") == 0) pkt->type = P_NAK;
     else pkt->type = P_BOGUS;
@@ -738,6 +740,11 @@ pkt_t *pkt;
                p->state = S_REPWAIT;
                break;
            }
+           else if(pkt->type == P_PREP) {
+               /* no ack, just rep */
+               p->state = S_REPWAIT;
+               break;
+           }
            /* else unexpected packet, put back on queue */
            pending_enqueue(p);
            return;
@@ -764,18 +771,26 @@ pkt_t *pkt;
            else if(action != A_RCVDATA)
                goto badaction;
            /* got the packet with the right handle, now check it */
-           if(pkt->type != P_REP) {
+           if(pkt->type != P_REP && pkt->type != P_PREP) {
+               pending_enqueue(p);
+               return;
+           }
+           if(pkt->type == P_REP) {
+               send_ack(p);
+               p->state = S_SUCCEEDED;
+               free_handle(p);
+               p->continuation(p, pkt);
+               amfree(p->req);
+               amfree(p->security);
+               amfree(p);
+               return;
+           }
+           else if(pkt->type == P_PREP) {
+               p->state = S_REPWAIT;
+               p->continuation(p, pkt);
                pending_enqueue(p);
                return;
            }
-           send_ack(p);
-           p->state = S_SUCCEEDED;
-           free_handle(p);
-           p->continuation(p, pkt);
-           amfree(p->req);
-           amfree(p->security);
-           amfree(p);
-           return;
 
        default:
        badaction:
@@ -936,7 +951,6 @@ static void handle_incoming_packet()
        if(errno == EAGAIN)
            return;
 #endif
-
        fprintf(stderr,"protocol packet receive: %s\n", strerror(errno));
     }