pier        00/11/30 13:59:03

  Modified:    connectors/webapplib wa_provider_warp.c wa_provider_warp.h
  Log:
  Bugfixes for multiplexing issues.
  Improving request handling.
  Changed packet type definitios.
  
  Revision  Changes    Path
  1.4       +93 -12    jakarta-tomcat-4.0/connectors/webapplib/wa_provider_warp.c
  
  Index: wa_provider_warp.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_provider_warp.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- wa_provider_warp.c        2000/11/30 19:54:08     1.3
  +++ wa_provider_warp.c        2000/11/30 21:58:59     1.4
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_provider_warp.c,v 1.3 2000/11/30 19:54:08 pier Exp $
  +// CVS $Id: wa_provider_warp.c,v 1.4 2000/11/30 21:58:59 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   #include <wa.h>
  @@ -225,22 +225,40 @@
       int rid=-1;
       int typ=-1;
       int siz=-1;
  +    int ret=-1;
   
       // Get the packet RID
  -    if ((rid=wa_warp_recv_short(c))<0) return(NULL);
  +    if ((rid=wa_warp_recv_short(c))<0) {
  +        fprintf(stderr,"NO RID (%d)\n",rid);
  +        return(NULL);
  +    }
  +
       // Fix this for multithreaded environments (demultiplexing of packets)
  -    if (rid!=r) return(NULL);
  +    if (rid!=r) {
  +        fprintf(stderr,"INVALID RID got %d expected %d\n",rid,r);
  +        return(NULL);
  +    }
  +
       // Get the packet TYPE
  -    if ((typ=wa_warp_recv_short(c))<0) return(NULL);
  +    if ((typ=wa_warp_recv_short(c))<0) {
  +        fprintf(stderr,"NO TYP rid=%d typ=%d\n",rid,typ);
  +        return(NULL);
  +    }
  +
       // Get the packet payload size
  -    if ((siz=wa_warp_recv_short(c))<0) return(NULL);
  +    if ((siz=wa_warp_recv_short(c))<0) {
  +        fprintf(stderr,"NO SIZ rid=%d typ=%d siz=%d\n",rid,typ,siz);
  +        return(NULL);
  +    }
  +
       // Create the packet
       p=wa_warp_packet_create(siz);
       p->typ=typ;
       p->siz=siz;
       if (siz==0) return(p);
       // Read from the socket and fill the packet buffer
  -    if (recv(c->sock,p->buf,siz,0)!=siz) {
  +    if ((ret=recv(c->sock,p->buf,siz,0))!=siz) {
  +        fprintf(stderr,"SHORT rid=%d typ=%d siz=%d ret=%d\n",rid,typ,siz,ret);
           wa_warp_packet_free(p);
           return(NULL);
       }
  @@ -463,7 +481,7 @@
           int hid=0;
   
           // Setup the packet
  -        p->typ=TYP_HOST;
  +        p->typ=TYP_CONINIT_HST;
           wa_warp_packet_set_string(p,host->name);
           wa_warp_packet_set_short(p,host->port);
   
  @@ -483,7 +501,7 @@
               return;
           }
           // Check if we got the right packet
  -        if (in->typ!=TYP_HOST_ID) {
  +        if (in->typ!=TYP_CONINIT_HID) {
               wa_warp_packet_free(p);
               wa_warp_packet_free(in);
               wa_warp_close(conf, "Cannot retrieve host ID (TYP)");
  @@ -497,7 +515,7 @@
               int aid=0;
               wa_warp_appl_config *cnf=NULL;
   
  -            p->typ=TYP_APPLICATION;
  +            p->typ=TYP_CONINIT_APP;
               wa_warp_packet_set_string(p,appl->name);
               wa_warp_packet_set_string(p,appl->path);
   
  @@ -517,7 +535,7 @@
                   return;
               }
               // Check if we got the right packet
  -            if (in->typ!=TYP_APPLICATION_ID) {
  +            if (in->typ!=TYP_CONINIT_AID) {
                   wa_warp_packet_free(p);
                   wa_warp_packet_free(in);
                   wa_warp_close(conf, "Cannot retrieve application ID (TYP)");
  @@ -596,6 +614,7 @@
       wa_warp_packet *in=NULL;
       wa_warp_packet *out=NULL;
       int rid=0;
  +    int x=0;
   
       cc=(wa_warp_conn_config *)req->appl->conn->conf;
       ac=(wa_warp_appl_config *)req->appl->conf;
  @@ -614,7 +633,7 @@
       out=wa_warp_packet_create(4096);
   
       // Let's start requesting the RID for this request.
  -    out->typ=TYP_REQUEST;
  +    out->typ=TYP_CONINIT_REQ;
       wa_warp_packet_set_short(out,ac->host);
       wa_warp_packet_set_short(out,ac->appl);
       if (!wa_warp_send(cc,RID_CONNECTION,out)) {
  @@ -634,7 +653,7 @@
           return;
       }
       // Check if we got the right packet
  -    if (in->typ!=TYP_REQUEST_ID) {
  +    if (in->typ!=TYP_CONINIT_RID) {
           wa_warp_packet_free(out);
           wa_warp_packet_free(in);
           wa_warp_close(cc, "Cannot retrieve request RID (TYP)");
  @@ -643,8 +662,70 @@
       }
       rid=wa_warp_packet_get_short(in);
       wa_warp_packet_free(in);
  +    
  +    // Send the request method
  +    wa_warp_packet_reset(out);
  +    out->typ=TYP_REQINIT_MET;
  +    wa_warp_packet_set_string(out,req->meth);
  +    wa_warp_send(cc,rid,out);
  +    
  +    // Send the request URI
  +    wa_warp_packet_reset(out);
  +    out->typ=TYP_REQINIT_URI;
  +    wa_warp_packet_set_string(out,req->ruri);
  +    wa_warp_send(cc,rid,out);
  +    
  +    // Send the request arguments
  +    wa_warp_packet_reset(out);
  +    out->typ=TYP_REQINIT_ARG;
  +    wa_warp_packet_set_string(out,req->args);
  +    wa_warp_send(cc,rid,out);
   
  +    // Send the request protocol
  +    wa_warp_packet_reset(out);
  +    out->typ=TYP_REQINIT_PRO;
  +    wa_warp_packet_set_string(out,req->prot);
  +    wa_warp_send(cc,rid,out);
  +
  +    // Send the request headers
  +    for (x=0; x<req->hnum; x++) {
  +        wa_warp_packet_reset(out);
  +        out->typ=TYP_REQINIT_HDR;
  +        wa_warp_packet_set_string(out,req->hnam[x]);
  +        wa_warp_packet_set_string(out,req->hval[x]);
  +        wa_warp_send(cc,rid,out);
  +    }
  +
  +    // Send the request variables (TODO)
  +
  +    // Try to issue a GO
  +    wa_warp_packet_reset(out);
  +    out->typ=TYP_REQINIT_RUN;
  +    wa_warp_send(cc,rid,out);
   
  +    // Retrieve the packet containing the ACK/ERR for this request
  +    in=wa_warp_recv(cc,rid);
  +    if (in==NULL) {
  +        wa_warp_packet_free(out);
  +        wa_warp_close(cc, "Cannot switch to passive mode");
  +        wa_warp_handle_error(req,cb,"Cannot switch to passive mode");
  +        return;
  +    }
  +    // Check if we got an ERR packet
  +    if (in->typ==TYP_REQINIT_ERR) {
  +        wa_warp_packet_free(out);
  +        wa_warp_packet_free(in);
  +        wa_warp_handle_error(req,cb,"Request not accepted by the server");
  +        return;
  +    }
  +    // Check if we got the right (ACK) packet
  +    if (in->typ!=TYP_REQINIT_ACK) {
  +        wa_warp_packet_free(out);
  +        wa_warp_packet_free(in);
  +        wa_warp_handle_error(req,cb,"Unknown packet received (%d)",in->typ);
  +        return;
  +    }
  +    wa_warp_packet_free(in);
   
       wa_callback_setstatus(cb,req,200);
       wa_callback_settype(cb,req,"text/html");
  
  
  
  1.3       +21 -9     jakarta-tomcat-4.0/connectors/webapplib/wa_provider_warp.h
  
  Index: wa_provider_warp.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/connectors/webapplib/wa_provider_warp.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- wa_provider_warp.h        2000/11/30 17:34:15     1.2
  +++ wa_provider_warp.h        2000/11/30 21:59:00     1.3
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -// CVS $Id: wa_provider_warp.h,v 1.2 2000/11/30 17:34:15 pier Exp $
  +// CVS $Id: wa_provider_warp.h,v 1.3 2000/11/30 21:59:00 pier Exp $
   // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]>
   
   /* The warp packet structure */
  @@ -85,11 +85,23 @@
   #define SOCKET_NOT_CREATED      -1
   
   /* Look in WarpConstants.java for a description of these definitions. */
  -#define RID_CONNECTION     0x00000
  -#define RID_DISCONNECT     0x0ffff
  -#define TYP_HOST           0x00000
  -#define TYP_HOST_ID        0x00001
  -#define TYP_APPLICATION    0x00002
  -#define TYP_APPLICATION_ID 0x00003
  -#define TYP_REQUEST        0x00004
  -#define TYP_REQUEST_ID     0x00005
  +#define RID_CONNECTION  0x00000
  +#define RID_DISCONNECT  0x0ffff
  +
  +#define TYP_CONINIT_HST 0x00000
  +#define TYP_CONINIT_HID 0x00001
  +#define TYP_CONINIT_APP 0x00002
  +#define TYP_CONINIT_AID 0x00003
  +#define TYP_CONINIT_REQ 0x00004
  +#define TYP_CONINIT_RID 0x00005
  +#define TYP_CONINIT_ERR 0x0000F
  +
  +#define TYP_REQINIT_MET 0x00010
  +#define TYP_REQINIT_URI 0x00011
  +#define TYP_REQINIT_ARG 0x00012
  +#define TYP_REQINIT_PRO 0x00013
  +#define TYP_REQINIT_HDR 0x00014
  +#define TYP_REQINIT_VAR 0x00015
  +#define TYP_REQINIT_RUN 0x0001D
  +#define TYP_REQINIT_ERR 0x0001E
  +#define TYP_REQINIT_ACK 0x0001F
  
  
  

Reply via email to