mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Stop the hard crash at the python level when maximum buffer size is exceeded
This commit is contained in:
parent
0b344e9a2b
commit
da0908002c
@ -237,10 +237,23 @@ inline bool Buffered_DatagramConnection::SendMessage(const Datagram &msg)
|
||||
// printf(" DO SendMessage %d\n",msg.get_length());
|
||||
int val = 0;
|
||||
val = _Writer.AddData(msg.get_data(),msg.get_length(),*this);
|
||||
if(val >= 0)
|
||||
return true;
|
||||
// Raise an exception to give us more information at the python level
|
||||
nativenet_cat.warning() << "Buffered_DatagramConnection::SendMessage->Error On Write--Out Buffer = " << _Writer.AmountBuffered() << "\n";
|
||||
#ifdef HAVE_PYTHON
|
||||
ostringstream s;
|
||||
PyObject *exc_type = PyExc_StandardError;
|
||||
|
||||
if(val >= 0)
|
||||
return true;
|
||||
nativenet_cat.error() << "Buffered_DatagramConnection::SendMessage->Error On Write--Out Buffer = " << _Writer.AmountBuffered() << "\n";
|
||||
s << endl << "Error sending message: " << endl;
|
||||
msg.dump_hex(s);
|
||||
|
||||
s << "Message data: " << msg.get_data() << endl;
|
||||
|
||||
string message = s.str();
|
||||
PyErr_SetString(exc_type, message.c_str());
|
||||
#endif
|
||||
|
||||
ClearAll();
|
||||
}
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user