Пример #1
0
int
wd_hb_recv(int sock, WdHbPacket * pkt)
{
	int rtn;
	struct sockaddr_in senderinfo;
	socklen_t addrlen;
	WdHbPacket buf;

	addrlen = sizeof(senderinfo);

	rtn = recvfrom(sock, &buf, sizeof(WdHbPacket), 0,
	               (struct sockaddr *)&senderinfo, &addrlen);
	if (rtn < 0)
	{	
		pool_error("wd_hb_recv: failed to receive packet");
		return WD_NG;
	}
	else if (rtn == 0)
	{
		pool_error("wd_hb_recv: received zero bytes");
		return WD_NG;
	}
	else
	{
		pool_debug("wd_hb_recv: received %d byte packet", rtn);
	}

	ntoh_wd_hb_packet(pkt, &buf);

	return WD_OK;
}
Пример #2
0
/* receive heartbeat signal */
void
wd_hb_recv(int sock, WdHbPacket * pkt)
{
	int rtn;
	struct sockaddr_in senderinfo;
	socklen_t addrlen;
	WdHbPacket buf;

	addrlen = sizeof(senderinfo);

	rtn = recvfrom(sock, &buf, sizeof(WdHbPacket), 0,
	               (struct sockaddr *)&senderinfo, &addrlen);
	if (rtn < 0)
		ereport(ERROR,
			(errmsg("failed to receive heartbeat packet")));
	else if (rtn == 0)
		ereport(ERROR,
				(errmsg("failed to receive heartbeat received zero length packet")));
	else
		ereport(DEBUG2,
				(errmsg("watchdog heartbeat: received %d byte packet", rtn)));

	ntoh_wd_hb_packet(pkt, &buf);
}