Update of /cvsroot/playerstage/code/player/client_libs/libplayerc
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19040/client_libs/libplayerc

Modified Files:
        client.c dev_blackboard.c dev_laser.c mclient.c playerc.h 
Log Message:
fixed error handling in read so it can timeout/exit properly on disconnection.
fixed a couple of warnings
added accessor for range data in libplayerc


Index: mclient.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/mclient.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** mclient.c   7 Dec 2007 01:50:14 -0000       1.10
--- mclient.c   17 Jan 2008 04:37:23 -0000      1.11
***************
*** 156,160 ****
         (mclient->pollfd[i].revents & POLLIN) > 0)
      {
!       if(playerc_client_read_nonblock(mclient->client[i]))
        {
          // cache the latest timestamp
--- 156,160 ----
         (mclient->pollfd[i].revents & POLLIN) > 0)
      {
!       if(playerc_client_read_nonblock(mclient->client[i])>0)
        {
          // cache the latest timestamp

Index: client.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/client.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -C2 -d -r1.92 -r1.93
*** client.c    15 Jan 2008 23:50:52 -0000      1.92
--- client.c    17 Jan 2008 04:37:23 -0000      1.93
***************
*** 577,581 ****
  void *playerc_client_read(playerc_client_t *client)
  {
!   void* ret;  
    // 10ms delay
    struct timespec sleeptime = {0,10000000};
--- 577,582 ----
  void *playerc_client_read(playerc_client_t *client)
  {
!   void* ret_proxy;
!   int ret;
    // 10ms delay
    struct timespec sleeptime = {0,10000000};
***************
*** 586,601 ****
      if(playerc_client_requestdata(client) < 0)
        return NULL;
!     ret = playerc_client_read_nonblock(client);
!     if((ret != NULL) || (client->sock < 0))
!       break;
      nanosleep(&sleeptime,NULL);
    }  
-   return(ret);
  }
  
  // Read and process a packet (nonblocking)
! void *playerc_client_read_nonblock(playerc_client_t *client)
  {
    player_msghdr_t header;
  
    while (true)
--- 587,613 ----
      if(playerc_client_requestdata(client) < 0)
        return NULL;
!     ret = playerc_client_read_nonblock_withproxy(client, &ret_proxy);
!     if((ret > 0) || (client->sock < 0))
!       return ret_proxy;
!     if (ret < 0)
!       return NULL;
      nanosleep(&sleeptime,NULL);
    }  
  }
  
+ 
  // Read and process a packet (nonblocking)
! // returns 0 if no data recieved, 1 if data recieved and -1 on error
! int playerc_client_read_nonblock(playerc_client_t *client)
! {
!       return playerc_client_read_nonblock_withproxy(client, NULL);
! }
! 
! // Read and process a packet (nonblocking), fills in pointer to proxy that 
got data
! // returns 0 if no data recieved, 1 if data recieved and -1 on error
! int playerc_client_read_nonblock_withproxy(playerc_client_t *client, void ** 
proxy)
  {
    player_msghdr_t header;
+   int ret;
  
    while (true)
***************
*** 605,613 ****
      {
        // If there is no queued data, peek at the socket
!       if(playerc_client_internal_peek(client,0) <= 0)
!         return NULL;
        // There's data on the socket, so read a packet (blocking).
!       if(playerc_client_readpacket (client, &header, client->data) < 0)
!         return NULL;
      }
          
--- 617,625 ----
      {
        // If there is no queued data, peek at the socket
!       if((ret = playerc_client_internal_peek(client,0)) <= 0)
!         return ret;
        // There's data on the socket, so read a packet (blocking).
!       if((ret = playerc_client_readpacket (client, &header, client->data)) < 
0)
!         return ret;
      }
          
***************
*** 624,632 ****
          {
            PLAYERC_WARN ("No data recieved with SYNC");
!           return NULL;
          }
          else
          {
!           return client->id;
          }
        case PLAYER_MSGTYPE_DATA:
--- 636,646 ----
          {
            PLAYERC_WARN ("No data recieved with SYNC");
!           return -1;
          }
          else
          {
!           if (proxy)
!             *proxy = client->id;
!           return 1;
          }
        case PLAYER_MSGTYPE_DATA:
***************
*** 639,643 ****
            // Need to ensure that any dynamic data made during unpacking is 
cleaned up
            playerxdr_cleanup_message(client->data, header.addr.interf, 
header.type, header.subtype);
!           return result;
          }
          else  // PULL mode, so keep on going
--- 653,659 ----
            // Need to ensure that any dynamic data made during unpacking is 
cleaned up
            playerxdr_cleanup_message(client->data, header.addr.interf, 
header.type, header.subtype);
!           if (proxy)
!             *proxy = result;
!           return 1;
          }
          else  // PULL mode, so keep on going
***************
*** 649,653 ****
            {
                PLAYERC_WARN ("Failed to dispatch data message");
!             return NULL;                
            }
            break;
--- 665,669 ----
            {
                PLAYERC_WARN ("Failed to dispatch data message");
!             return -1;
            }
            break;
***************
*** 661,665 ****
                 header.addr.index,
                 header.size);
!         return NULL;
      }
    }
--- 677,681 ----
                 header.addr.index,
                 header.size);
!         return -1;
      }
    }

Index: playerc.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/playerc.h,v
retrieving revision 1.245
retrieving revision 1.246
diff -C2 -d -r1.245 -r1.246
*** playerc.h   9 Jan 2008 11:45:36 -0000       1.245
--- playerc.h   17 Jan 2008 04:37:23 -0000      1.246
***************
*** 727,731 ****
  
  // Read and process a packet (nonblocking)
! void *playerc_client_read_nonblock(playerc_client_t *client);
  
  /** @brief Set the timeout for client requests.
--- 727,735 ----
  
  // Read and process a packet (nonblocking)
! // returns 0 if no data recieved, 1 if data recieved and -1 on error
! int playerc_client_read_nonblock(playerc_client_t *client);
! // Read and process a packet (nonblocking), fills in pointer to proxy that 
got data
! // returns 0 if no data recieved, 1 if data recieved and -1 on error
! int playerc_client_read_nonblock_withproxy(playerc_client_t *client, void ** 
proxy);
  
  /** @brief Set the timeout for client requests.

Index: dev_blackboard.c
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/client_libs/libplayerc/dev_blackboard.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** dev_blackboard.c    26 Nov 2007 22:14:59 -0000      1.5
--- dev_blackboard.c    17 Jan 2008 04:37:23 -0000      1.6
***************
*** 96,100 ****
  
        if (playerc_client_request(device->info.client, &device->info, 
!       PLAYER_BLACKBOARD_REQ_SUBSCRIBE_TO_KEY, &req, entry_out) < 0)
        {
                free(req.key);
--- 96,100 ----
  
        if (playerc_client_request(device->info.client, &device->info, 
!       PLAYER_BLACKBOARD_REQ_SUBSCRIBE_TO_KEY, &req, (void**)entry_out) < 0)
        {
                free(req.key);

Index: dev_laser.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/dev_laser.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** dev_laser.c 16 Dec 2007 20:50:47 -0000      1.47
--- dev_laser.c 17 Jan 2008 04:37:23 -0000      1.48
***************
*** 209,213 ****
                           double scanning_frequency)
  {
!   player_laser_config_t config, *resp;
  
    config.min_angle = min_angle;
--- 209,213 ----
                           double scanning_frequency)
  {
!   player_laser_config_t config;
  
    config.min_angle = min_angle;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
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