Update of /cvsroot/playerstage/code/player/client_libs/libplayerc
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19444/client_libs/libplayerc
Modified Files:
client.c mclient.c playerc.h
Log Message:
fixed up message delivery semantics
Index: mclient.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/mclient.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** mclient.c 1 Mar 2006 02:58:17 -0000 1.8
--- mclient.c 2 Nov 2007 18:09:20 -0000 1.9
***************
*** 133,136 ****
--- 133,144 ----
mclient->pollfd[i].events = POLLIN;
mclient->pollfd[i].revents = 0;
+ // If the client is in a PULL mode, first request a round of data.
+ if(mclient->client[i]->mode == PLAYER_DATAMODE_PULL)
+ {
+ if(playerc_client_requestdata(mclient->client[i]) < 0)
+ {
+ PLAYERC_ERR("playerc_client_requestdata errored");
+ }
+ }
}
***************
*** 148,152 ****
if ((mclient->pollfd[i].revents & POLLIN) > 0)
{
! if(playerc_client_read(mclient->client[i]))
{
// cache the latest timestamp
--- 156,160 ----
if ((mclient->pollfd[i].revents & POLLIN) > 0)
{
! if(playerc_client_read_nonblock(mclient->client[i]))
{
// cache the latest timestamp
Index: client.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/client.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -C2 -d -r1.85 -r1.86
*** client.c 2 Nov 2007 02:41:11 -0000 1.85
--- client.c 2 Nov 2007 18:09:20 -0000 1.86
***************
*** 171,174 ****
--- 171,175 ----
client->mode = PLAYER_DATAMODE_PULL;
client->transport = PLAYERC_TRANSPORT_TCP;
+ client->data_requested = 0;
client->request_timeout = 5.0;
***************
*** 504,511 ****
playerc_client_requestdata(playerc_client_t* client)
{
player_null_t req;
// req.subtype = htons(PLAYER_PLAYER_DATA_REQ);
! return(playerc_client_request(client, NULL, PLAYER_PLAYER_REQ_DATA, &req,
NULL));
}
--- 505,518 ----
playerc_client_requestdata(playerc_client_t* client)
{
+ int ret;
player_null_t req;
// req.subtype = htons(PLAYER_PLAYER_DATA_REQ);
! if(client->data_requested)
! return(0);
! ret = playerc_client_request(client, NULL, PLAYER_PLAYER_REQ_DATA, &req,
NULL);
! if(ret == 0)
! client->data_requested = 1;
! return(ret);
}
***************
*** 532,536 ****
fd.fd = client->sock;
! fd.events = POLLIN | POLLHUP;
fd.revents = 0;
--- 539,544 ----
fd.fd = client->sock;
! //fd.events = POLLIN | POLLHUP;
! fd.events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL;
fd.revents = 0;
***************
*** 566,569 ****
--- 574,583 ----
for(;;)
{
+ // If we're in a PULL mode, first request a round of data.
+ if((client->mode == PLAYER_DATAMODE_PULL))
+ {
+ if(playerc_client_requestdata(client) < 0)
+ return NULL;
+ }
ret = playerc_client_read_nonblock(client);
if(ret != NULL)
***************
*** 581,607 ****
int got_data=0;
! // If we're in a PULL mode, first request a round of data.
! if (client->mode == PLAYER_DATAMODE_PULL)
! {
! if (playerc_client_requestdata(client) < 0)
! return NULL;
! }
! // Otherwise, peek at the socket
! else
{
if(playerc_client_peek(client,0) <= 0)
return NULL;
}
while (true)
{
! // See if there is any queued data.
! if (playerc_client_pop (client, &header, client->data) < 0)
! {
! // If there is no queued data, read a packet (blocking).
! if (playerc_client_readpacket (client, &header, client->data) < 0)
! return NULL;
! }
!
switch(header.type)
{
--- 595,612 ----
int got_data=0;
! // See if there is any queued data.
! if (playerc_client_pop (client, &header, client->data) < 0)
{
+ // If there is no queued data, peek at the socket
if(playerc_client_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;
}
while (true)
{
! // One way or another, we got a new packet into (header,client->data), so
process it
switch(header.type)
{
***************
*** 609,612 ****
--- 614,618 ----
break;
case PLAYER_MSGTYPE_SYNCH:
+ client->data_requested = 0;
if(!got_data)
return NULL;
***************
*** 631,635 ****
return NULL;
got_data = 1;
! continue;
}
default:
--- 637,641 ----
return NULL;
got_data = 1;
! break;
}
default:
***************
*** 643,646 ****
--- 649,662 ----
return NULL;
}
+ // See if there is any queued data.
+ if (playerc_client_pop (client, &header, client->data) < 0)
+ {
+ // If there is no queued data, peek at the socket
+ if(playerc_client_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;
+ }
}
}
***************
*** 980,984 ****
nbytes = timed_recv(client->sock,
client->read_xdrdata + client->read_xdrdata_len,
! PLAYERXDR_MAX_MESSAGE_SIZE - client->read_xdrdata_len,
0, client->request_timeout * 1e3);
if (nbytes <= 0)
--- 996,1000 ----
nbytes = timed_recv(client->sock,
client->read_xdrdata + client->read_xdrdata_len,
! PLAYERXDR_MSGHDR_SIZE - client->read_xdrdata_len,
0, client->request_timeout * 1e3);
if (nbytes <= 0)
***************
*** 1025,1029 ****
nbytes = timed_recv(client->sock,
client->read_xdrdata + client->read_xdrdata_len,
! PLAYERXDR_MAX_MESSAGE_SIZE - client->read_xdrdata_len,
0, client->request_timeout*1e3);
if (nbytes <= 0)
--- 1041,1045 ----
nbytes = timed_recv(client->sock,
client->read_xdrdata + client->read_xdrdata_len,
! header->size - client->read_xdrdata_len,
0, client->request_timeout*1e3);
if (nbytes <= 0)
Index: playerc.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/playerc.h,v
retrieving revision 1.238
retrieving revision 1.239
diff -C2 -d -r1.238 -r1.239
*** playerc.h 2 Nov 2007 02:41:11 -0000 1.238
--- playerc.h 2 Nov 2007 18:09:20 -0000 1.239
***************
*** 465,468 ****
--- 465,472 ----
uint8_t mode;
+ /** @internal Data request flag; if mode == PLAYER_DATAMODE_PULL, have we
+ * requested and not yet received a round of data? */
+ int data_requested;
+
/** List of available (but not necessarily subscribed) devices.
This list is filled in by playerc_client_get_devlist(). */
-------------------------------------------------------------------------
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