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

Modified Files:
      Tag: b_thjc_dynamic_arrays
        playertcp.h .cvsignore playerudp.cc playertcp.cc socket_util.c 
        socket_util.h 
Log Message:
Merged some changes from head a while back

Work on updating drivers, A-J done,  laser is next

Index: .cvsignore
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** .cvsignore  5 May 2006 06:20:00 -0000       1.2
--- .cvsignore  10 Oct 2007 09:26:04 -0000      1.2.2.1
***************
*** 3,4 ****
--- 3,9 ----
  playertcp.pc
  playerudp.pc
+ .libs
+ .deps
+ *.la
+ *.a
+ *.lo

Index: playertcp.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/playertcp.h,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -C2 -d -r1.23 -r1.23.2.1
*** playertcp.h 23 Aug 2007 19:58:42 -0000      1.23
--- playertcp.h 10 Oct 2007 09:26:04 -0000      1.23.2.1
***************
*** 141,147 ****
--- 141,150 ----
      ~PlayerTCP();
  
+     static void InitGlobals(void);
+ 
      pthread_t thread;
  
      int Listen(int* ports, int num_ports);
+     int Listen(int port);
      QueuePointer AddClient(struct sockaddr_in* cliaddr, 
                              unsigned int local_host,
***************
*** 150,153 ****
--- 153,157 ----
                              bool send_banner,
                              int* kill_flag);
+     int Update(int timeout);
      int Accept(int timeout);
      void Close(int cli);

Index: playertcp.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/playertcp.cc,v
retrieving revision 1.57.2.1
retrieving revision 1.57.2.2
diff -C2 -d -r1.57.2.1 -r1.57.2.2
*** playertcp.cc        10 Sep 2007 04:11:01 -0000      1.57.2.1
--- playertcp.cc        10 Oct 2007 09:26:04 -0000      1.57.2.2
***************
*** 111,114 ****
--- 111,121 ----
  } playertcp_conn_t;
  
+ void
+ PlayerTCP::InitGlobals(void)
+ {
+   player_globals_init();
+   ErrorInit(9);
+   playerxdr_ftable_init();
+ }
  
  PlayerTCP::PlayerTCP()
***************
*** 174,178 ****
    {
      if((this->listeners[i].fd =
!         create_and_bind_socket(1,this->host,ports[i],
                                 PLAYER_TRANSPORT_TCP,200)) < 0)
      {
--- 181,185 ----
    {
      if((this->listeners[i].fd =
!         create_and_bind_socket(1,this->host,ports+i,
                                 PLAYER_TRANSPORT_TCP,200)) < 0)
      {
***************
*** 190,193 ****
--- 197,207 ----
  }
  
+ int
+ PlayerTCP::Listen(int port)
+ {
+   int p = port;
+   return(this->Listen(&p,1));
+ }
+ 
  // should be called with client_mutex locked
  QueuePointer
***************
*** 272,275 ****
--- 286,299 ----
  
  int
+ PlayerTCP::Update(int timeout)
+ {
+   int ret;
+   this->Write();
+   if((ret = this->Accept(0)))
+     return(ret);
+   return(this->Read(timeout));
+ }
+ 
+ int
  PlayerTCP::Accept(int timeout)
  {
***************
*** 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->GetPayloadSize() 
+ msg->GetDynDataSize()));
          if(maxsize > (size_t)(client->writebuffersize))
          {
--- 598,602 ----
          // 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.
--- 657,686 ----
          }
  
!         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);
--- 911,915 ----
            if(hdr.addr.interf == PLAYER_PLAYER_CODE)
            {
!             Message* msg = new Message(hdr, this->decode_readbuffer, 
client->queue);
              assert(msg);
              this->HandlePlayerMessage(cli, msg);
***************
*** 941,945 ****
            // class destructs).
            if (decode_msglen > 0)
!             playerxdr_delete_message(this->decode_readbuffer, 
hdr.addr.interf, hdr.type, hdr.subtype);
          }
        }
--- 970,974 ----
            // class destructs).
            if (decode_msglen > 0)
!             playerxdr_cleanup_message(this->decode_readbuffer, 
hdr.addr.interf, hdr.type, hdr.subtype);
          }
        }
***************
*** 1003,1007 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp, sizeof(devresp));
              assert(resp);
              client->queue->Push(*resp);
--- 1032,1036 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1122,1126 ****
            }
            devlist.devices_count = numdevices;
- 
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
            // Make up and push out the reply
--- 1151,1154 ----
***************
*** 1154,1158 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL, 0);
              assert(resp);
              client->queue->Push(*resp);
--- 1182,1186 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1189,1193 ****
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1217,1221 ----
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1208,1212 ****
            // 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);
--- 1236,1240 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1219,1223 ****
            // 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);
--- 1247,1251 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1235,1239 ****
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1263,1267 ----
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1249,1253 ****
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL, 0);
        assert(resp);
        client->queue->Push(*resp);
--- 1277,1281 ----
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL);
        assert(resp);
        client->queue->Push(*resp);

Index: socket_util.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/socket_util.c,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** socket_util.c       10 Jul 2007 09:01:52 -0000      1.3
--- socket_util.c       10 Oct 2007 09:26:04 -0000      1.3.2.1
***************
*** 83,87 ****
  
  int
! create_and_bind_socket(char blocking, unsigned int host, int portnum, 
                         int playersocktype, int backlog)
  {
--- 83,87 ----
  
  int
! create_and_bind_socket(char blocking, unsigned int host, int* portnum, 
                         int playersocktype, int backlog)
  {
***************
*** 106,110 ****
    memset(&serverp,0,sizeof(serverp));
    serverp.sin_addr.s_addr = host;
!   serverp.sin_port = htons(portnum);
  
    /* 
--- 106,110 ----
    memset(&serverp,0,sizeof(serverp));
    serverp.sin_addr.s_addr = host;
!   serverp.sin_port = htons(*portnum);
  
    /* 
***************
*** 184,187 ****
--- 184,190 ----
    }
  
+   // Copy back the selected port (in case the OS changed it)
+   *portnum = ntohs(serverp.sin_port);
+ 
    /* if it's TCP, go ahead with listen() */
    if(socktype == SOCK_STREAM)

Index: playerudp.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/playerudp.cc,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -C2 -d -r1.6.2.1 -r1.6.2.2
*** playerudp.cc        10 Sep 2007 04:11:01 -0000      1.6.2.1
--- playerudp.cc        10 Oct 2007 09:26:04 -0000      1.6.2.2
***************
*** 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);
***************
*** 877,881 ****
            // 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);
          }
        }
--- 876,880 ----
            // 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);
          }
        }
***************
*** 939,943 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp, sizeof(devresp));
              assert(resp);
              client->queue->Push(*resp);
--- 938,942 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, &devresp);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1090,1094 ****
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL, 0);
              assert(resp);
              client->queue->Push(*resp);
--- 1089,1093 ----
  
              // Make up and push out the reply
!             resp = new Message(resphdr, NULL);
              assert(resp);
              client->queue->Push(*resp);
***************
*** 1125,1129 ****
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1124,1128 ----
  
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1144,1148 ****
            // 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);
--- 1143,1147 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1155,1159 ****
            // 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);
--- 1154,1158 ----
            // Make up and push out the reply
            resphdr.type = PLAYER_MSGTYPE_RESP_ACK;
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1171,1175 ****
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL, 0);
            assert(resp);
            client->queue->Push(*resp);
--- 1170,1174 ----
            resphdr.size = 0;
            // Make up and push out the reply
!           resp = new Message(resphdr, NULL);
            assert(resp);
            client->queue->Push(*resp);
***************
*** 1185,1189 ****
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL, 0);
        assert(resp);
        client->queue->Push(*resp);
--- 1184,1188 ----
        resphdr.size = 0;
        // Make up and push out the reply
!       resp = new Message(resphdr, NULL);
        assert(resp);
        client->queue->Push(*resp);

Index: socket_util.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayertcp/socket_util.h,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** socket_util.h       10 Jul 2007 09:01:52 -0000      1.3
--- socket_util.h       10 Oct 2007 09:26:04 -0000      1.3.2.1
***************
*** 77,81 ****
   */
  int create_and_bind_socket(char blocking, unsigned int host, 
!                            int portnum, int socktype, int backlog);
  #ifdef __cplusplus
  }
--- 77,81 ----
   */
  int create_and_bind_socket(char blocking, unsigned int host, 
!                            int* portnum, int socktype, int backlog);
  #ifdef __cplusplus
  }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to