Skip to content
Snippets Groups Projects
Commit c5ac632a authored by Per Hedbor's avatar Per Hedbor
Browse files

Fixed a few things in Remote.pmod

Rev: lib/modules/Remote.pmod/call.pike:1.4
Rev: lib/modules/Remote.pmod/connection.pike:1.5
parent b225b8ed
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ mixed sync(mixed ... args) ...@@ -25,7 +25,7 @@ mixed sync(mixed ... args)
void async(mixed ... args) void async(mixed ... args)
{ {
mixed data = ctx->encode_call(objectid, name, args, _async); mixed data = ctx->encode_call(objectid, name, args, 1);
con->call_async(data); con->call_async(data);
} }
......
...@@ -94,16 +94,15 @@ void closed_connection(int|void ignore) ...@@ -94,16 +94,15 @@ void closed_connection(int|void ignore)
string write_buffer = ""; string write_buffer = "";
void write_some(int|void ignore) void write_some(int|void ignore)
{ {
if(closed) return; if(closed) {
write_buffer="";
return;
}
int c; int c;
if (!sizeof(write_buffer)) if (!sizeof(write_buffer))
return; return;
c = con->write(write_buffer); c = con->write(write_buffer);
if(c <= 0) if(c <= 0) return;
{
closed_connection();
return;
}
write_buffer = write_buffer[c..]; write_buffer = write_buffer[c..];
DEBUGMSG("wrote "+c+" bytes\n"); DEBUGMSG("wrote "+c+" bytes\n");
} }
...@@ -154,6 +153,7 @@ void return_error(int refno, mixed err) ...@@ -154,6 +153,7 @@ void return_error(int refno, mixed err)
void return_value(int refno, mixed val) void return_value(int refno, mixed val)
{ {
string s = encode_value(ctx->encode_return(refno, val)); string s = encode_value(ctx->encode_return(refno, val));
DEBUGMSG("return "+strlen(s)+" bytes ["+refno+"]\n");
send(sprintf("%4c%s", sizeof(s), s)); send(sprintf("%4c%s", sizeof(s), s));
} }
...@@ -182,11 +182,12 @@ void read_some(int ignore, string s) ...@@ -182,11 +182,12 @@ void read_some(int ignore, string s)
if (!s) s = ""; if (!s) s = "";
DEBUGMSG("read "+sizeof(s)+" bytes\n"); DEBUGMSG("read "+sizeof(s)+" bytes\n");
read_buffer += s; read_buffer += s;
DEBUGMSG("has "+sizeof(read_buffer)+" bytes\n");
if(!strlen(read_buffer)) return;
if (!request_size && sizeof(read_buffer) > 4) if (!request_size && sizeof(read_buffer) > 4)
{ {
sscanf(read_buffer, "%4c%s", request_size, read_buffer); sscanf(read_buffer, "%4c%s", request_size, read_buffer);
DEBUGMSG("reading message of size "+request_size+"\n");
} }
if (request_size && sizeof(read_buffer) >= request_size) if (request_size && sizeof(read_buffer) >= request_size)
...@@ -225,7 +226,7 @@ void read_some(int ignore, string s) ...@@ -225,7 +226,7 @@ void read_some(int ignore, string s)
int refno = data[1]; int refno = data[1];
mixed result = ctx->decode(data[2]); mixed result = ctx->decode(data[2]);
if (!pending_calls[refno]) if (!pending_calls[refno])
error("Got an answer I didn't ask for (refno="+refno+")"); error("Got return for odd call: "+refno+"\n");
DEBUGMSG("providing the result for request "+refno+": "+ DEBUGMSG("providing the result for request "+refno+": "+
ctx->describe(data)+"\n"); ctx->describe(data)+"\n");
provide_result(refno, result); provide_result(refno, result);
...@@ -234,6 +235,7 @@ void read_some(int ignore, string s) ...@@ -234,6 +235,7 @@ void read_some(int ignore, string s)
default: default:
error("Unknown message"); error("Unknown message");
} }
if(sizeof(read_buffer) > 4) read_some(ignore,"");
} }
} }
...@@ -273,7 +275,7 @@ void call_async(array data) ...@@ -273,7 +275,7 @@ void call_async(array data)
{ {
if(closed) error("connection closed\n"); if(closed) error("connection closed\n");
string s = encode_value(data); string s = encode_value(data);
DEBUGMSG("call_sync "+ctx->describe(data)+"\n"); DEBUGMSG("call_async "+ctx->describe(data)+"\n");
send(sprintf("%4c%s", sizeof(s), s)); send(sprintf("%4c%s", sizeof(s), s));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment