static unsigned int nr_fds;
static int sock = -1;
-static int ro_sock = -1;
static bool verbose = false;
LIST_HEAD(connections);
return -1;
}
-static void initialize_fds(int *p_sock_pollfd_idx, int *p_ro_sock_pollfd_idx,
- int *ptimeout)
+static void initialize_fds(int *p_sock_pollfd_idx, int *ptimeout)
{
struct connection *conn;
struct wrl_timestampt now;
if (sock != -1)
*p_sock_pollfd_idx = set_fd(sock, POLLIN|POLLPRI);
- if (ro_sock != -1)
- *p_ro_sock_pollfd_idx = set_fd(ro_sock, POLLIN|POLLPRI);
if (reopen_log_pipe[0] != -1)
reopen_log_pipe0_pollfd_idx =
set_fd(reopen_log_pipe[0], POLLIN|POLLPRI);
unsigned int i;
enum xs_perm_type mask = XS_PERM_READ|XS_PERM_WRITE|XS_PERM_OWNER;
- if (!conn->can_write)
- mask &= ~XS_PERM_WRITE;
-
/* Owners and tools get it all... */
if (!domain_is_unprivileged(conn) || perms[0].id == conn->id
|| (conn->target && perms[0].id == conn->target->id))
new->pollfd_idx = -1;
new->write = write;
new->read = read;
- new->can_write = true;
new->transaction_started = 0;
INIT_LIST_HEAD(&new->out_list);
INIT_LIST_HEAD(&new->watches);
}
#ifdef NO_SOCKETS
-static void accept_connection(int sock, bool canwrite)
+static void accept_connection(int sock)
{
}
#else
return rc;
}
-static void accept_connection(int sock, bool canwrite)
+static void accept_connection(int sock)
{
int fd;
struct connection *conn;
return;
conn = new_connection(writefd, readfd);
- if (conn) {
+ if (conn)
conn->fd = fd;
- conn->can_write = canwrite;
- } else
+ else
close(fd);
}
#endif
{
if (sock >= 0)
close(sock);
- if (ro_sock >= 0)
- close(ro_sock);
}
static void init_sockets(void)
{
struct sockaddr_un addr;
const char *soc_str = xs_daemon_socket();
- const char *soc_str_ro = xs_daemon_socket_ro();
/* Create sockets for them to listen to. */
atexit(destroy_fds);
sock = socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0)
barf_perror("Could not create socket");
- ro_sock = socket(PF_UNIX, SOCK_STREAM, 0);
- if (ro_sock < 0)
- barf_perror("Could not create socket");
/* FIXME: Be more sophisticated, don't mug running daemon. */
unlink(soc_str);
- unlink(soc_str_ro);
addr.sun_family = AF_UNIX;
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0)
barf_perror("Could not bind socket to %s", soc_str);
- if(strlen(soc_str_ro) >= sizeof(addr.sun_path))
- barf_perror("socket string '%s' too long", soc_str_ro);
- strcpy(addr.sun_path, soc_str_ro);
- if (bind(ro_sock, (struct sockaddr *)&addr, sizeof(addr)) != 0)
- barf_perror("Could not bind socket to %s", soc_str_ro);
-
- if (chmod(soc_str, 0600) != 0
- || chmod(soc_str_ro, 0660) != 0)
+ if (chmod(soc_str, 0600) != 0)
barf_perror("Could not chmod sockets");
- if (listen(sock, 1) != 0 || listen(ro_sock, 1) != 0)
+ if (listen(sock, 1) != 0)
barf_perror("Could not listen on sockets");
}
#endif
int main(int argc, char *argv[])
{
int opt;
- int sock_pollfd_idx = -1, ro_sock_pollfd_idx = -1;
+ int sock_pollfd_idx = -1;
bool dofork = true;
bool outputpid = false;
bool no_domain_init = false;
tracefile = talloc_strdup(NULL, tracefile);
/* Get ready to listen to the tools. */
- initialize_fds(&sock_pollfd_idx, &ro_sock_pollfd_idx, &timeout);
+ initialize_fds(&sock_pollfd_idx, &timeout);
/* Tell the kernel we're up and running. */
xenbus_notify_running();
barf_perror("sock poll failed");
break;
} else if (fds[sock_pollfd_idx].revents & POLLIN) {
- accept_connection(sock, true);
+ accept_connection(sock);
sock_pollfd_idx = -1;
}
}
- if (ro_sock_pollfd_idx != -1) {
- if (fds[ro_sock_pollfd_idx].revents & ~POLLIN) {
- barf_perror("ro sock poll failed");
- break;
- } else if (fds[ro_sock_pollfd_idx].revents & POLLIN) {
- accept_connection(ro_sock, false);
- ro_sock_pollfd_idx = -1;
- }
- }
-
if (xce_pollfd_idx != -1) {
if (fds[xce_pollfd_idx].revents & ~POLLIN) {
barf_perror("xce_handle poll failed");
}
}
- initialize_fds(&sock_pollfd_idx, &ro_sock_pollfd_idx, &timeout);
+ initialize_fds(&sock_pollfd_idx, &timeout);
}
}