* See the file LICENSE for details.
*
* $Log: yaz-pdu-assoc.cpp,v $
- * Revision 1.19 2000-11-01 14:22:59 adam
+ * Revision 1.20 2000-11-20 11:27:33 adam
+ * Fixes for connect operation (timeout and notify fix).
+ *
+ * Revision 1.19 2000/11/01 14:22:59 adam
* Added fd parameter for method IYaz_PDU_Observer::clone.
*
* Revision 1.18 2000/10/24 12:29:57 adam
void Yaz_PDU_Assoc::socketNotify(int event)
{
logf (m_log, "Yaz_PDU_Assoc::socketNotify p=%p event = %d", this, event);
- if (0 /* m_state == Connected */)
- {
- m_state = Ready;
- m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ|
- YAZ_SOCKET_OBSERVE_EXCEPT);
- m_PDU_Observer->connectNotify();
- flush_PDU();
- }
- else if (m_state == Connecting)
+ switch (m_state)
{
+ case Connecting:
if (event & YAZ_SOCKET_OBSERVE_READ)
{
close();
m_PDU_Observer->connectNotify();
flush_PDU();
}
- }
- else if (m_state == Listen)
- {
+ break;
+ case Listen:
if (event & YAZ_SOCKET_OBSERVE_READ)
{
int res;
cs_close (new_line);
childNotify(fd);
}
- }
- else if (m_state == Ready)
- {
+ break;
+ case Ready:
if (event & YAZ_SOCKET_OBSERVE_WRITE)
{
flush_PDU();
{
m_PDU_Observer->timeoutNotify();
}
+ break;
+ case Closed:
+ logf (m_log, "CLOSING state=%d event was %d", m_state, event);
+ close();
+ m_PDU_Observer->failNotify();
+ break;
+ default:
+ logf (m_log, "Unknown state=%d event was %d", m_state, event);
+ close();
+ m_PDU_Observer->failNotify();
}
}
logf (m_log, "Yaz_PDU_Assoc::connect fd=%d res=%d", cs_fileno(cs), res);
m_socketObservable->addObserver(cs_fileno(cs), this);
m_socketObservable->maskObserver(this, YAZ_SOCKET_OBSERVE_READ|
- YAZ_SOCKET_OBSERVE_EXCEPT|
- YAZ_SOCKET_OBSERVE_WRITE);
- m_state = Connecting;
+ YAZ_SOCKET_OBSERVE_EXCEPT|
+ YAZ_SOCKET_OBSERVE_WRITE);
+ if (res >= 0)
+ m_state = Connecting;
+ // if res < 0, then cs_connect failed immediately. state is Closed..
}
void Yaz_PDU_Assoc::socket(IYaz_PDU_Observer *observer, int fd)
* See the file LICENSE for details.
*
* $Log: yaz-proxy.cpp,v $
- * Revision 1.21 2000-11-01 14:22:59 adam
+ * Revision 1.22 2000-11-20 11:27:33 adam
+ * Fixes for connect operation (timeout and notify fix).
+ *
+ * Revision 1.21 2000/11/01 14:22:59 adam
* Added fd parameter for method IYaz_PDU_Observer::clone.
*
* Revision 1.20 2000/10/24 12:29:57 adam
c->m_last_resultCount = 0;
c->m_sr_transform = 0;
c->m_waiting = 0;
- c->timeout(600);
+ c->timeout(10);
(parent->m_seqno)++;
}
void Yaz_ProxyClient::connectNotify()
{
- logf (LOG_LOG, "Yaz_ProxyClient connection accept by %s", get_hostname());
+ logf (LOG_LOG, "Yaz_ProxyClient connection accepted by %s",
+ get_hostname());
+ timeout(600);
}
IYaz_PDU_Observer *Yaz_ProxyClient::clone(IYaz_PDU_Observable
* See the file LICENSE for details.
*
* $Log: yaz-socket-manager.cpp,v $
- * Revision 1.12 2000-10-24 12:29:57 adam
+ * Revision 1.13 2000-11-20 11:27:33 adam
+ * Fixes for connect operation (timeout and notify fix).
+ *
+ * Revision 1.12 2000/10/24 12:29:57 adam
* Fixed bug in proxy where a Yaz_ProxyClient could be owned by
* two Yaz_Proxy's (fatal).
*
timeout_this = p->timeout;
if (p->last_activity)
timeout_this -= now - p->last_activity;
+ else
+ p->last_activity = now;
if (timeout_this < 1)
timeout_this = 1;
if (!timeout || timeout_this < timeout)
now >= p->last_activity + (int) (p->timeout))
{
YazSocketEvent *event = new YazSocketEvent;
- logf (LOG_LOG, "timeout now = %ld last_activity=%ld timeout=%d",
+ logf (m_log, "timeout, now = %ld last_activity=%ld timeout=%d",
now, p->last_activity, p->timeout);
p->last_activity = now;
event->observer = p->observer;