* Copyright (c) 1998-2001, Index Data.
* See the file LICENSE for details.
*
- * $Id: yaz-pdu-assoc.cpp,v 1.28 2002-10-09 12:50:26 adam Exp $
+ * $Id: yaz-pdu-assoc.cpp,v 1.29 2003-07-25 19:27:36 adam Exp $
*/
#include <assert.h>
// assume comstack is accepting...
m_state = Accepting;
m_socketObservable->addObserver(cs_fileno(cs), this);
+ yaz_log(m_log, "maskObserver 1");
m_socketObservable->maskObserver(this,
mask |YAZ_SOCKET_OBSERVE_EXCEPT);
}
}
else
{ // accept still incomplete.
+ yaz_log(m_log, "maskObserver 2");
m_socketObservable->maskObserver(this,
mask|YAZ_SOCKET_OBSERVE_EXCEPT);
}
mask |= YAZ_SOCKET_OBSERVE_WRITE;
if (m_cs->io_pending & CS_WANT_READ)
mask |= YAZ_SOCKET_OBSERVE_READ;
+ yaz_log(m_log, "maskObserver 3");
m_socketObservable->maskObserver(this, mask);
}
else
mask |= YAZ_SOCKET_OBSERVE_WRITE;
if (m_cs->io_pending & CS_WANT_READ)
mask |= YAZ_SOCKET_OBSERVE_READ;
+ yaz_log(m_log, "maskObserver 4");
m_socketObservable->maskObserver(this, mask);
return;
}
if (destroyed) // it really was destroyed, return now.
return;
} while (m_cs && cs_more (m_cs));
- if (m_cs)
+ if (m_cs && m_state == Ready)
+ {
+ yaz_log(m_log, "maskObserver 5");
m_socketObservable->maskObserver(this,
YAZ_SOCKET_OBSERVE_EXCEPT|
YAZ_SOCKET_OBSERVE_READ);
+ }
}
break;
case Closed:
{
m_state = Ready;
yaz_log (m_log, "YAZ_PDU_Assoc::flush_PDU queue empty");
+ yaz_log(m_log, "maskObserver 6");
m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ|
YAZ_SOCKET_OBSERVE_WRITE|
YAZ_SOCKET_OBSERVE_EXCEPT);
mask |= YAZ_SOCKET_OBSERVE_WRITE;
if (m_cs->io_pending & CS_WANT_READ)
mask |= YAZ_SOCKET_OBSERVE_READ;
-
+
+ mask |= YAZ_SOCKET_OBSERVE_WRITE;
+ yaz_log(m_log, "maskObserver 7");
m_socketObservable->maskObserver(this, mask);
- yaz_log (m_log, "Yaz_PDU_Assoc::flush_PDU cs_put %d bytes (incomp)",
- q->m_len);
+ yaz_log (m_log, "Yaz_PDU_Assoc::flush_PDU cs_put %d bytes fd=%d (inc)",
+ q->m_len, cs_fileno(m_cs));
return r;
}
- m_state = Ready;
yaz_log (m_log, "Yaz_PDU_Assoc::flush_PDU cs_put %d bytes", q->m_len);
// whole packet sent... delete this and proceed to next ...
m_queue_out = q->m_next;
delete q;
// don't select on write if queue is empty ...
if (!m_queue_out)
+ {
+ m_state = Ready;
+ yaz_log(m_log, "maskObserver 8");
m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ|
YAZ_SOCKET_OBSERVE_EXCEPT);
+ }
return r;
}
if (cs_bind(m_cs, ap, CS_SERVER) < 0)
return;
m_socketObservable->addObserver(cs_fileno(m_cs), this);
+ yaz_log(m_log, "maskObserver 9");
m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ|
YAZ_SOCKET_OBSERVE_EXCEPT);
yaz_log (m_log, "Yaz_PDU_Assoc::listen ok fd=%d", cs_fileno(m_cs));
mask |= YAZ_SOCKET_OBSERVE_WRITE;
if (m_cs->io_pending & CS_WANT_READ)
mask |= YAZ_SOCKET_OBSERVE_READ;
+ yaz_log(m_log, "maskObserver 11");
m_socketObservable->maskObserver(this, mask);
}
else
{ // Connect failed immediately
// Since m_state is Closed we can distinguish this case from
// normal connect in socketNotify handler
+ yaz_log(m_log, "maskObserver 12");
m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_WRITE|
YAZ_SOCKET_OBSERVE_EXCEPT);
}