Skip to content

Commit

Permalink
incomplete C++ client fix
Browse files Browse the repository at this point in the history
  • Loading branch information
s-u committed Oct 9, 2015
1 parent 7999d12 commit 3c1c7d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/client/cxx/Rconnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,18 @@ int Rmessage::read(int s) {
closesocket(s); s=-1;
return (n==0)?-7:-8;
}
Rsize_t i=len=head.len=ptoi(head.len);
head.cmd=ptoi(head.cmd);
head.dof=ptoi(head.dof);
head.res=ptoi(head.res);
if (head.dof>0) { // skip past DOF if present
char sb[256];
int k=head.dof;
while (k>0) {
n=recv(s,(char*)sb,(k>256)?256:k,0);
if (n<1) {
closesocket(s); s=-1;
return -8; // malformed packet
}
k-=n;
}
Rsize_t i = len = (unsigned int) (head.len = ptoi(head.len));
head.cmd = ptoi(head.cmd);
head.msg_id = ptoi(head.msg_id);
head.res = ptoi(head.res);
#ifdef __LP64__
if (head.res) { /* process high bits of the length */
unsigned int len_lo = (unsigned int) head.len;
len |= ((Rsize_t)ph.res) << 32;
i = len;
}
#endif

if (i>0) {
data=(char*) malloc(i);
if (!data) {
Expand Down Expand Up @@ -222,7 +218,7 @@ void Rmessage::parse() {
len|=((Rsize_t)p2)<<24;
}
#ifdef DEBUG_CXX
printf(" par %d: %d length %d\n", pars, p1&0x3f, len);
printf(" par %d: %d length %ld\n", pars, p1&0x3f, (long) len);
#endif
par[pars++]=(unsigned int*)c;
c+=hs;
Expand All @@ -235,15 +231,15 @@ int Rmessage::send(int s) {
int failed=0;
head.cmd=itop(head.cmd);
head.len=itop(head.len);
head.dof=itop(head.dof);
head.msg_id=itop(head.msg_id);
head.res=itop(head.res);
if (::send(s,(char*)&head,sizeof(head),0)!=sizeof(head))
failed=-1;
if (!failed && len>0 && (Rsize_t)::send(s,data,len,0)!=len)
failed=-1;
head.cmd=ptoi(head.cmd);
head.len=ptoi(head.len);
head.dof=ptoi(head.dof);
head.msg_id=ptoi(head.msg_id);
head.res=ptoi(head.res);
return failed;
}
Expand Down Expand Up @@ -272,13 +268,13 @@ Rexp::Rexp(unsigned int *pos, Rmessage *msg) {
next=parse(pos);
}

Rexp::Rexp(int type, const char *data, int len, Rexp *attr) {
Rexp::Rexp(int type, const char *data, Rsize_t len, Rexp *attr) {
this->attr=attr; master=this; rcount=0; attribs=0;
this->type=type;
this->msg=0;
if (len>0) {
#ifdef DEBUG_CXX
fprintf(stderr, "Rexp::Rexp %p: allocating %d bytes\n", this, len);
fprintf(stderr, "Rexp::Rexp %p: allocating %lu bytes\n", this, (unsigned long) len);
#endif
this->data=(char*) malloc(len);
memcpy(this->data, data, len);
Expand Down
4 changes: 4 additions & 0 deletions src/client/cxx/Rconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
#include "sisocks.h"
#include "Rsrv.h"

#ifdef __LP64__
typedef unsigned long Rsize_t;
#else
typedef unsigned int Rsize_t;
#endif

//=== Rconnection error codes

Expand Down

0 comments on commit 3c1c7d2

Please sign in to comment.