Skip to content

Commit 90c0321

Browse files
committed
Fix for broken pipe crash
1 parent 7537770 commit 90c0321

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

sockets/include/ml_sockets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/** MODULE SPECIFIC INFORMATION **/
3030
#define MODULE_NAME "Sockets Module"
3131
#define MODULE_AUTHOR "Gamesnert, MCvarial & x86"
32-
#define MODULE_VERSION 1.2f
32+
#define MODULE_VERSION 1.3f
3333

3434
// Include default MTA module SDK includes
3535
#include "Common.h"

sockets/src/CSocket.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ bool CSocket::Send(const string& data)
7676
if (m_pSocket == ERR_INVALID_SOCKET)
7777
return false;
7878

79-
// Pretend zero length send was ok
80-
if (data.length() == 0)
81-
return true;
82-
8379
// Send the data and return whether it was successful
8480
return (send(m_pSocket, data.c_str(), data.length(), 0) != ERR_SEND_FAILURE);
8581
}

sockets/src/ml_sockets.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "ml_sockets.h"
2020
#include "luaimports.h"
21+
#include <signal.h>
2122

2223
ILuaModuleManager10 *pModuleManager = NULL;
2324

@@ -40,6 +41,9 @@ MTAEXPORT bool InitModule ( ILuaModuleManager10 *pManager, char *szModuleName, c
4041
pModuleManager->ErrorPrintf("[Sockets] Can't start Winsock, aborting...");
4142
return false;
4243
}
44+
#else
45+
// Avoid process termination on broken pipe
46+
signal(SIGPIPE, SIG_IGN);
4347
#endif
4448

4549
return true;

0 commit comments

Comments
 (0)