Update of /cvsroot/playerstage/code/player/libplayertcp
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7891/libplayertcp

Modified Files:
        playerudp.cc playertcp.cc 
Log Message:
Changes to message class to remove option to set size explicitly.
This only work by coincidence for structures with one array at the end of them.
Also Message class now uses the auto generated clone and free methods.

Index: playerudp.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/playerudp.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** playerudp.cc        23 Aug 2007 19:58:42 -0000      1.6
--- playerudp.cc        21 Sep 2007 03:31:49 -0000      1.7
***************
*** 579,583 ****
          // Make sure there's room in the buffer for the encoded messsage.
          // 4 times the message is a safe upper bound
!         size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * (msg->GetPayloadSize() 
+ msg->GetDynDataSize()));
          if(maxsize > (size_t)(client->writebuffersize))
          {
--- 579,583 ----
          // Make sure there's room in the buffer for the encoded messsage.
          // 4 times the message is a safe upper bound
!         size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * msg->GetDataSize());
          if(maxsize > (size_t)(client->writebuffersize))
          {
***************
*** 817,822 ****
            if(hdr.addr.interf == PLAYER_PLAYER_CODE)
            {
!             Message* msg = new Message(hdr, this->decode_readbuffer,
!                                        hdr.size, client->queue);
              assert(msg);
              this->HandlePlayerMessage(cli, msg);
--- 817,821 ----
            if(hdr.addr.interf == PLAYER_PLAYER_CODE)
            {
!             Message* msg = new Message(hdr, this->decode_readbuffer, 
client->queue);
              assert(msg);
              this->HandlePlayerMessage(cli, msg);
***************
*** 875,879 ****
            // makes another copy of this data that will be cleaned up when 
that Message
            // class destructs).
!           playerxdr_delete_message(this->decode_readbuffer, hdr.addr.interf, 
hdr.type, hdr.subtype);
          }
        }
--- 874,878 ----
            // makes another copy of this data that will be cleaned up when 
that Message
            // class destructs).
!           playerxdr_cleanup_message(this->decode_readbuffer, hdr.addr.interf, 
hdr.type, hdr.subtype);
          }
        }
***************
*** 937,941 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp, sizeof(devresp));
              assert(resp);
              client->queue->Push(*resp);
--- 936,940 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1088,1092 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL, 0);
              assert(resp);
              client->queue->Push(*resp);
--- 1087,1091 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1123,1127 ****
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1122,1126 ----
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1142,1146 ****
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1141,1145 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1153,1157 ****
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1152,1156 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1169,1173 ****
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1168,1172 ----
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1183,1187 ****
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL, 0);
        assert(resp);
        client->queue->Push(*resp);
--- 1182,1186 ----
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL);
        assert(resp);
        client->queue->Push(*resp);

Index: playertcp.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/playertcp.cc,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** playertcp.cc        20 Sep 2007 05:34:47 -0000      1.59
--- playertcp.cc        21 Sep 2007 03:31:49 -0000      1.60
***************
*** 574,578 ****
          // Make sure there's room in the buffer for the encoded messsage.
          // 4 times the message (including dynamic data) is a safe upper bound
!         size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * msg->GetDynDataSize());
          if(maxsize > (size_t)(client->writebuffersize))
          {
--- 574,578 ----
          // Make sure there's room in the buffer for the encoded messsage.
          // 4 times the message (including dynamic data) is a safe upper bound
!         size_t maxsize = PLAYERXDR_MSGHDR_SIZE + (4 * msg->GetDataSize());
          if(maxsize > (size_t)(client->writebuffersize))
          {
***************
*** 633,656 ****
          }
  
!         // Encode the body first
!         if((encode_msglen =
!             (*packfunc)(client->writebuffer + PLAYERXDR_MSGHDR_SIZE,
                          maxsize - PLAYERXDR_MSGHDR_SIZE,
                          payload, PLAYERXDR_ENCODE)) < 0)
!         {
!           PLAYER_WARN4("encoding failed on message from %s:%u with type 
%s:%u",
                         interf_to_str(hdr.addr.interf), hdr.addr.index, 
msgtype_to_str(hdr.type), hdr.subtype);
  #if HAVE_ZLIB_H
!           if(zipped_data)
!           {
!             free(zipped_data);
!             zipped_data=NULL;
!           }
  #endif
!           client->writebufferlen = 0;
!           delete msg;
!           return(0);
          }
- 
          // Rewrite the size in the header with the length of the encoded
          // body, then encode the header.
--- 633,662 ----
          }
  
!         if (payload)
!           {
!           // Encode the body first
!           if((encode_msglen =
!               (*packfunc)(client->writebuffer + PLAYERXDR_MSGHDR_SIZE,
                          maxsize - PLAYERXDR_MSGHDR_SIZE,
                          payload, PLAYERXDR_ENCODE)) < 0)
!           {
!             PLAYER_WARN4("encoding failed on message from %s:%u with type 
%s:%u",
                         interf_to_str(hdr.addr.interf), hdr.addr.index, 
msgtype_to_str(hdr.type), hdr.subtype);
  #if HAVE_ZLIB_H
!             if(zipped_data)
!             {
!               free(zipped_data);
!               zipped_data=NULL;
!             }
  #endif
!             client->writebufferlen = 0;
!             delete msg;
!             return(0);
!           }
!         }
!         else
!         {
!           encode_msglen = 0;
          }
          // Rewrite the size in the header with the length of the encoded
          // body, then encode the header.
***************
*** 881,886 ****
            if(hdr.addr.interf == PLAYER_PLAYER_CODE)
            {
!             Message* msg = new Message(hdr, this->decode_readbuffer,
!                                        hdr.size, client->queue);
              assert(msg);
              this->HandlePlayerMessage(cli, msg);
--- 887,891 ----
            if(hdr.addr.interf == PLAYER_PLAYER_CODE)
            {
!             Message* msg = new Message(hdr, this->decode_readbuffer, 
client->queue);
              assert(msg);
              this->HandlePlayerMessage(cli, msg);
***************
*** 940,944 ****
            // class destructs).
            if (decode_msglen > 0)
!             playerxdr_delete_message(this->decode_readbuffer, 
hdr.addr.interf, hdr.type, hdr.subtype);
          }
        }
--- 945,949 ----
            // class destructs).
            if (decode_msglen > 0)
!             playerxdr_cleanup_message(this->decode_readbuffer, 
hdr.addr.interf, hdr.type, hdr.subtype);
          }
        }
***************
*** 1002,1006 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp, sizeof(devresp));
              assert(resp);
              client->queue->Push(*resp);
--- 1007,1011 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1152,1156 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL, 0);
              assert(resp);
              client->queue->Push(*resp);
--- 1157,1161 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1187,1191 ****
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1192,1196 ----
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1206,1210 ****
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1211,1215 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1217,1221 ****
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1222,1226 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1233,1237 ****
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1238,1242 ----
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1247,1251 ****
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL, 0);
        assert(resp);
        client->queue->Push(*resp);
--- 1252,1256 ----
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL);
        assert(resp);
        client->queue->Push(*resp);


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to