mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
pstats: Start new session if client disconnects before sending data
This provides a better UX; if the client disconnects after the graphs open, it's quite obvious that there's still a PStats session open, but otherwise it's not obvious (and a little annoying) if you have to realize that PStats is no longer listening and you have to start a new session.
This commit is contained in:
parent
21cae91890
commit
1fa446e183
@ -69,12 +69,21 @@ make_monitor(const NetAddress &address) {
|
|||||||
*/
|
*/
|
||||||
void GtkStatsServer::
|
void GtkStatsServer::
|
||||||
lost_connection(PStatMonitor *monitor) {
|
lost_connection(PStatMonitor *monitor) {
|
||||||
// Store a backup now, in case PStats crashes or something.
|
if (_monitor != nullptr && !_monitor->_have_data) {
|
||||||
_last_session.make_dir();
|
// We didn't have any data yet. Just silently restart the session.
|
||||||
if (monitor->write(_last_session)) {
|
_monitor->close();
|
||||||
nout << "Wrote to " << _last_session << "\n";
|
_monitor = nullptr;
|
||||||
|
if (new_session()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nout << "Failed to write to " << _last_session << "\n";
|
// Store a backup now, in case PStats crashes or something.
|
||||||
|
_last_session.make_dir();
|
||||||
|
if (monitor->write(_last_session)) {
|
||||||
|
nout << "Wrote to " << _last_session << "\n";
|
||||||
|
} else {
|
||||||
|
nout << "Failed to write to " << _last_session << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_listening();
|
stop_listening();
|
||||||
|
@ -81,12 +81,21 @@ make_monitor(const NetAddress &address) {
|
|||||||
*/
|
*/
|
||||||
void WinStatsServer::
|
void WinStatsServer::
|
||||||
lost_connection(PStatMonitor *monitor) {
|
lost_connection(PStatMonitor *monitor) {
|
||||||
// Store a backup now, in case PStats crashes or something.
|
if (_monitor != nullptr && !_monitor->_have_data) {
|
||||||
_last_session.make_dir();
|
// We didn't have any data yet. Just silently restart the session.
|
||||||
if (monitor->write(_last_session)) {
|
_monitor->close();
|
||||||
nout << "Wrote to " << _last_session << "\n";
|
_monitor = nullptr;
|
||||||
|
if (new_session()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nout << "Failed to write to " << _last_session << "\n";
|
// Store a backup now, in case PStats crashes or something.
|
||||||
|
_last_session.make_dir();
|
||||||
|
if (monitor->write(_last_session)) {
|
||||||
|
nout << "Wrote to " << _last_session << "\n";
|
||||||
|
} else {
|
||||||
|
nout << "Failed to write to " << _last_session << "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_listening();
|
stop_listening();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user