View Issue Details

IDProjectCategoryView StatusLast Update
0000738LDMud 3.3Networkingpublic2010-07-13 13:38
ReporterWildcat Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Product Version3.3.719 
Summary0000738: pending input lost on socket close
DescriptionThis is probably by design for a player, but not so much for non players...

I have a small web script that makes a connection to a remote web server with net_connect and does work with it's output. The issue is that the cgi it invoked did not send a \n before closing the connection, so the last line of the output never makes it back to object when disconnect() is applied.

There should be a way to access the pending input even if it's just a 2nd argument to the applied disconnect(), I realize that for 99% of the time this is probably going to be useless but the devil is in the details of the last 1%.
TagsNo tags attached.
Attached Files
t-0000738.c (815 bytes)   
#pragma save_types, rtt_checks
#include "/inc/base.inc"
#include "/inc/client.inc"

void receive_nl()
{
    // Just to make sure.
    call_out(#'shutdown, __HEART_BEAT_INTERVAL__, 1);
    
    input_to("receive_cmd");
}

void receive_cmd(string str)
{
    input_to("receive_cmd");

    if(!sizeof(str))
    {
        remove_call_out(#'shutdown);
        shutdown(0);
    }
}

void send_nl()
{
    write("\n");
    remove_interactive(this_object());
}

void run_test()
{
    msg("\nRunning test for #0000738:\n"
          "--------------------------\n");

    /* We'll send a newline and close the connection.
     * This test succeeds if the input_to on the other
     * end receives an empty string.
     */
    connect_self("receive_nl", "send_nl");
}

string *epilog(int eflag)
{
    run_test();
    return 0;
}
t-0000738.c (815 bytes)   
t-0000738-a.c (842 bytes)   
#pragma save_types, rtt_checks
#include "/inc/base.inc"
#include "/inc/client.inc"

void receive_nl()
{
    // Just to make sure.
    call_out(#'shutdown, __HEART_BEAT_INTERVAL__, 1);
    
	input_to(#'receive_cmd);
}

void receive_cmd(string str)
{
	input_to(#'receive_cmd);

    if(sizeof(str))
    {
        remove_call_out(#'shutdown);
        shutdown(0);
    }
}

void send_no_nl()
{
    write("This will not be received");
    remove_interactive(this_object());
}

void run_test()
{
    msg("\nRunning test for #0000738:\n"
          "--------------------------\n");

    /* We'll send text and *no* new line and close the connection.
     * This test succeeds if the input_to on the other
     * end receives any text
     */
    connect_self("receive_nl", "send_no_nl");
}

string *epilog(int eflag)
{
    run_test();
    return 0;
}
t-0000738-a.c (842 bytes)   
t-0000738-b.c (1,027 bytes)   
#pragma save_types, rtt_checks
#include "/inc/base.inc"
#include "/inc/client.inc"
#include "/sys/input_to.h"

void receive_nl()
{
    // Just to make sure.
    call_out(#'shutdown, __HEART_BEAT_INTERVAL__, 1);
    
    set_combine_charset("abcdefghijklmnoprstuvwxz0123456789ABCDEFGHIJKLMNOPRSTUVWXZ ");
    input_to("receive_cmd", INPUT_CHARMODE);
}

void receive_cmd(string str)
{
    msg("Received: %Q\n", str);
    input_to("receive_cmd", INPUT_CHARMODE);

    if(sizeof(str))
    {
        remove_call_out(#'shutdown);
        shutdown(0);
    }
}

void send_no_nl()
{
    write("This will not be received");
    remove_interactive(this_object());
}

void run_test()
{
    msg("\nRunning test for #0000738:\n"
          "--------------------------\n");

    /* We'll send text and *no* new line and close the connection.
     * This test succeeds if the input_to on the other
     * end receives any text
     */
    connect_self("receive_nl", "send_no_nl");
}

string *epilog(int eflag)
{
    run_test();
    return 0;
}
t-0000738-b.c (1,027 bytes)   

Activities

Gnomi

2010-03-23 05:03

manager   ~0001812

I can't reproduce the problem. I've attached my test case (to execute it put it in the test/ folder of the driver sources and start './run.sh t-0000738.c' there), this test case succeeds. Could you provide a test case that fails (or modify mine accordingly)?

Wildcat

2010-03-23 08:39

reporter   ~0001813

Hmm my note got eaten when I went to upload the file, bad Firefox!

That wasn't quite what I had meant, I have modified the test to be what I intended but I'm traveling at the moment so am not able to run it. However, my intent should be more clear from the modified test.

Gnomi

2010-03-23 08:50

manager   ~0001814

Oh sorry, I misunderstood the bug report. I modified the test case to use INPUT_CHARMODE (otherwise input_to would wait for the newline) and it succeeds. (I added a set_combine_charset call, so input_to would show the whole string and not just one character at a time, but that doesn't affect the performance of the sender.) I uploaded the slightly modified test case.

Wildcat

2010-03-23 11:22

reporter   ~0001815

I'd forgotten about INPUT_CHARMODE, that would solve the issue I'm having and i'll modify my object to use it. This ticket can be closed.

zesstra

2010-04-26 15:22

administrator   ~0001837

Closing then. :-)

zesstra

2010-06-16 01:55

administrator   ~0001868

Fippo asked me to re-open this issue. He mentioned something psyclpc does in this respect. Maybe he can add some details here.

fippo

2010-06-16 02:51

reporter   ~0001869

actually, the patch I had in mind is already contained in ldmud since 2006:
http://github.com/zesstra/ldmud-mirror/commit/4c416cb584d9ec716763014ead2cca549c89bef0

master::disconnect receives the remaining buffer as a second argument. We call a disconnected() hook in the object with that info, where it can be processed as needed.

;-)

Issue History

Date Modified Username Field Change
2010-03-19 08:55 Wildcat New Issue
2010-03-23 05:00 Gnomi File Added: t-0000738.c
2010-03-23 05:03 Gnomi Note Added: 0001812
2010-03-23 08:38 Wildcat File Added: t-0000738-a.c
2010-03-23 08:39 Wildcat Note Added: 0001813
2010-03-23 08:46 Gnomi File Added: t-0000738-b.c
2010-03-23 08:50 Gnomi Note Added: 0001814
2010-03-23 11:22 Wildcat Note Added: 0001815
2010-04-26 15:22 zesstra Note Added: 0001837
2010-04-26 15:22 zesstra Status new => closed
2010-04-26 15:22 zesstra Resolution open => no change required
2010-06-16 01:55 zesstra Note Added: 0001868
2010-06-16 01:55 zesstra Status closed => feedback
2010-06-16 01:55 zesstra Resolution no change required => reopened
2010-06-16 02:51 fippo Note Added: 0001869
2010-07-13 13:38 zesstra Status feedback => closed
2010-07-13 13:38 zesstra Resolution reopened => no change required