Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] program stops with exit status 141, sf::TcpSocket::send()  (Read 20275 times)

0 Members and 1 Guest are viewing this topic.

takkai

  • Newbie
  • *
  • Posts: 8
    • View Profile
[SOLVED] program stops with exit status 141, sf::TcpSocket::send()
« on: September 07, 2012, 06:57:43 pm »
Hi,
in my tcp server my loop is like this

loop:
   r[] = receive clients
   ret = process r
   send clients ret
 

when the clients disconnect, they send a "I'm disconnecting" message to the server.
currently my server just ignores it (while I'm trying to make a game server that don't trust the client)
then when the server sends to the disconnected client, the server exits without any error message, only the returned status from the program $? being 141.

If I modify the clients to wait 2 seconds after sending their last message and before disconnecting the socket, then the server don't crash and continue to serve the other clients, because then it receives the status sf::Socket::Disconnected from the next socket->receive() call.

What did I make wrong?
How can I fix this?

(I'm using a recent git snapshot, 2012-08-20)
Thanks
« Last Edit: September 08, 2012, 10:29:29 pm by takkai »

takkai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #1 on: September 07, 2012, 07:15:59 pm »
I get the same problem in the client.

If the server was stopped (or crashed) the client just stops without any error message with the tcpSocket->send() call.

This call doesn't return any sf::Socket::Status that I could use, it just crashes the program without any error message and an exit code of 141.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #2 on: September 07, 2012, 07:32:54 pm »
Can you use your debugger to see what happens?
Laurent Gomila - SFML developer

takkai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #3 on: September 07, 2012, 08:47:50 pm »
so with gdb:

Program received signal SIGPIPE, Broken pipe.
0xffffe430 in __kernel_vsyscall ()

(gdb) bt
#0  0xffffe430 in __kernel_vsyscall ()
#1  0xb7edb8d1 in send () from /lib/i686/libc.so.6
#2  0xb7fdc11a in sf::TcpSocket::send(void const*, unsigned int) () from /temp/SFML_git/lib/libsfml-network.so.2
....

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #4 on: September 07, 2012, 09:31:11 pm »
Laurent Gomila - SFML developer

takkai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #5 on: September 08, 2012, 12:14:47 am »
Yes, indeed if I modify TcpSocket.cpp with this code (Linux) the behavior is what I expected.

So, what should I do if I plan to share my app in the future? Will 2.0 use the fix given in the issue? Or should I modify my code in some way to workaround the SIGPIPE?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #6 on: September 08, 2012, 09:26:51 am »
It will be fixed soon, but not in SFML 2.0 (maybe 2.1).
Laurent Gomila - SFML developer

takkai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #7 on: September 08, 2012, 05:54:21 pm »
OK, I understand.

So how should I handle this problem in the code I want to share?

takkai

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #8 on: September 08, 2012, 07:18:22 pm »
Hi again,

so in hope to make my code work with a vanilla SFML 2.0, I've tryed this work around:

    sigset_t set;
    sigaddset(&set, SIGPIPE);
    int retcode = sigprocmask(SIG_BLOCK, &set, NULL);
    if (retcode == -1) error("sigprocmask");

please tell me if it's a good way to do this, and if not how I should do.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #9 on: September 08, 2012, 07:26:38 pm »
If it works, then yes it's a good workaround :P
Laurent Gomila - SFML developer

takkai

  • Newbie
  • *
  • Posts: 8
    • View Profile
[SOLVED] Re: program stops with exit status 141, sf::TcpSocket::send()
« Reply #10 on: September 08, 2012, 10:28:12 pm »
Yes it seems to work.
I was still asking because I'm ignorant about networking.

Thanks you very much for your help!

 

anything