Deleted Added
full compact
32c32
< __FBSDID("$FreeBSD: head/sbin/hastd/hastd.c 218138 2011-01-31 18:32:17Z pjd $");
---
> __FBSDID("$FreeBSD: head/sbin/hastd/hastd.c 218218 2011-02-03 11:39:49Z pjd $");
216a217,229
> } else if (fd == proto_descriptor(res->hr_conn)) {
> if (!isopen) {
> snprintf(msg, sizeof(msg),
> "Descriptor %d (conn) is closed, but should be open.",
> fd);
> break;
> }
> if (!S_ISSOCK(mode)) {
> snprintf(msg, sizeof(msg),
> "Descriptor %d (conn) is %s, but should be %s.",
> fd, dtype2str(mode), dtype2str(S_IFSOCK));
> break;
> }
804a818,852
> connection_migrate(struct hast_resource *res)
> {
> struct proto_conn *conn;
> int16_t val = 0;
>
> if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) {
> pjdlog_errno(LOG_WARNING,
> "Unable to receive connection command");
> return;
> }
> if (proto_client(res->hr_remoteaddr, &conn) < 0) {
> val = errno;
> pjdlog_errno(LOG_WARNING,
> "Unable to create outgoing connection to %s",
> res->hr_remoteaddr);
> goto out;
> }
> if (proto_connect(conn, -1) < 0) {
> val = errno;
> pjdlog_errno(LOG_WARNING, "Unable to connect to %s",
> res->hr_remoteaddr);
> proto_close(conn);
> goto out;
> }
> val = 0;
> out:
> if (proto_send(res->hr_conn, &val, sizeof(val)) < 0) {
> pjdlog_errno(LOG_WARNING,
> "Unable to send reply to connection request");
> }
> if (val == 0 && proto_connection_send(res->hr_conn, conn) < 0)
> pjdlog_errno(LOG_WARNING, "Unable to send connection");
> }
>
> static void
860a909
> PJDLOG_ASSERT(res->hr_conn != NULL);
864a914,920
> if (res->hr_role == HAST_ROLE_PRIMARY) {
> /* Only primary workers asks for connections. */
> fd = proto_descriptor(res->hr_conn);
> PJDLOG_ASSERT(fd >= 0);
> FD_SET(fd, &rfds);
> maxfd = fd > maxfd ? fd : maxfd;
> }
884a941
> PJDLOG_ASSERT(res->hr_conn != NULL);
890a948,950
> proto_close(res->hr_conn);
> res->hr_conn = NULL;
> continue;
891a952,955
> if (res->hr_role == HAST_ROLE_PRIMARY &&
> FD_ISSET(proto_descriptor(res->hr_conn), &rfds)) {
> connection_migrate(res);
> }