mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -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());
|
// printf(" DO SendMessage %d\n",msg.get_length());
|
||||||
int val = 0;
|
int val = 0;
|
||||||
val = _Writer.AddData(msg.get_data(),msg.get_length(),*this);
|
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)
|
s << endl << "Error sending message: " << endl;
|
||||||
return true;
|
msg.dump_hex(s);
|
||||||
nativenet_cat.error() << "Buffered_DatagramConnection::SendMessage->Error On Write--Out Buffer = " << _Writer.AmountBuffered() << "\n";
|
|
||||||
|
s << "Message data: " << msg.get_data() << endl;
|
||||||
|
|
||||||
|
string message = s.str();
|
||||||
|
PyErr_SetString(exc_type, message.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
ClearAll();
|
ClearAll();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user