2019-07-28 10:31:56 +08:00
|
|
|
|
#include "stdafx.h"
|
2015-04-26 00:11:10 +08:00
|
|
|
|
#include "check_async.h"
|
|
|
|
|
|
|
|
|
|
check_async::check_async(acl::check_client& checker)
|
|
|
|
|
: checker_(checker)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check_async::~check_async(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool check_async::read_callback(char* data, int len)
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><>Ϊ acl <20><><EFBFBD>첽 IO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ϶<DDBF><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \0<><30>
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD>ӵ<EFBFBD><D3B5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƚ<EFBFBD><C8BD>ڴ˴<DAB4><CBB4>ǰ<EFBFBD>ȫ<EFBFBD><C8AB>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
|
|
|
|
|
if (strncasecmp(data, "+OK", 3) == 0)
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> QUIT <20><><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
checker_.get_conn().format("QUIT\r\n");
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>״̬
|
2015-04-26 00:11:10 +08:00
|
|
|
|
checker_.set_alive(true);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>رոü<D5B8><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
checker_.close();
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD> true <20><> false <20><><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>رռ<D8B1><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
printf(">>> NIO_CHECK SERVER(%s) OK: %s, len: %d <<<\r\n",
|
|
|
|
|
checker_.get_addr(), data, len);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> QUIT <20><><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
checker_.get_conn().format("QUIT\r\n");
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
2015-04-26 00:11:10 +08:00
|
|
|
|
checker_.set_alive(false);
|
|
|
|
|
|
|
|
|
|
printf(">>> NIO_CHECK SERVER(%s) ERROR: %s, len: %d <<<\r\n",
|
|
|
|
|
checker_.get_addr(), data, len);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> false ֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>رո<D8B1><D5B8><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool check_async::timeout_callback()
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
checker_.set_alive(false);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> false ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>رոü<D5B8><C3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void check_async::close_callback()
|
|
|
|
|
{
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>̬ɾ<CCAC><C9BE>
|
2015-04-26 00:11:10 +08:00
|
|
|
|
delete this;
|
|
|
|
|
}
|