1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00

unlink detection rewrite - please test this

This commit is contained in:
psyc://psyced.org/~lynX 2011-01-19 22:19:34 +01:00
parent 6b8e138eb4
commit b4867481f4
7 changed files with 70 additions and 36 deletions

View file

@ -474,9 +474,11 @@ int disconnected(string remaining) {
#endif
// wow.. a sincerely expected disconnect!
if (flags & TCP_PENDING_DISCONNECT) return 1;
#ifndef _flag_disable_report_failure_network_circuit_disconnect
#ifdef _flag_enable_report_failure_network_circuit_disconnect
monitor_report("_failure_network_circuit_disconnect",
object_name(ME) +" · lost PSYC circuit");
#else
P1(("%O disconnected unexpectedly\n", ME))
#endif
return 0; // unexpected
}

View file

@ -19,7 +19,8 @@ inherit PSYC_PATH "circuit";
// keep a list of objects to ->disconnected() when the driver tells us
volatile array(object) disconnect_notifies;
void do_notify_on_disconnect(object user) {
void register_link(object user) {
P4(("disconnect_notifies for %O in %O\n", user, ME))
unless(disconnect_notifies)
disconnect_notifies = ({ });
disconnect_notifies += ({ user });
@ -54,11 +55,10 @@ protected quit() { QUIT }
// self-destruct when the TCP link gets lost
disconnected(remaining) {
P2(( "%O got disconnected.\n", ME))
// emulate disconnected() for net/psyc/user
if (disconnect_notifies) {
foreach (object t : disconnect_notifies)
if (t) t->disconnected();
if (disconnect_notifies) foreach (object t : disconnect_notifies) {
P3(( "%O disconnecting %O\n", ME, t))
if (t) t->link_disconnected();
}
::disconnected(remaining);
QUIT // returns unexpected.. TODO

View file

@ -1,6 +1,7 @@
// $Id: user.c,v 1.15 2008/12/09 19:27:32 lynx Exp $ // vim:syntax=lpc
//
// handler for PSYC clients
// should be a dummy user object since all user objects
// must be able to handle PSYC clients
#include "common.h"
#include <net.h>
@ -12,14 +13,19 @@ logon() {
#ifdef NO_EXTERNAL_LOGINS
return destruct(ME);
#endif
#if 0
// psyc users dont have their own socket, so the driver
// does not call disconnected() for them - this enables the
// psyc socket to do that
if (this_interactive()) this_interactive()->do_notify_on_disconnect(ME);
// basically a good idea, but the wrong place to do this. since we
// want to be notified about any of n possible psyc clients we need
// to do this in linkSet(). --lynX
if (this_interactive()) this_interactive()->register_link(ME);
// connection that is creating us, died while we got here.
// rare, but does indeed happen sometimes.
else return destruct(ME);
// i presume the else case is better handled by disconnected() --lynX
#endif
// no lang support here either
vSet("scheme", "psyc");
return ::logon();
@ -27,10 +33,10 @@ logon() {
// errors only, it says
pr(mc, fmt, a,b,c,d,e,f,g,h) {
#if 1 //def PRO_PATH
if (abbrev("_message",mc)) return;
if (v("location"))
sendmsg(v("location"), mc+"_print", sprintf(fmt, a,b,c,d,e,f,g,h) );
#if 1 //ndef DEVELOPMENT
//if (abbrev("_message",mc)) return;
foreach (string location : v("locations")[0])
sendmsg(location, mc+"_print", sprintf(fmt, a,b,c,d,e,f,g,h) );
#else
// checkVar() still calls pr() .... grmlblmblm TODO
raise_error("pr() called\n");