/*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
struct stream stream;
int fd;
- char *unlink_path;
};
static const struct stream_class stream_fd_class;
* and stores a pointer to the stream in '*streamp'. Initial connection status
* 'connect_status' is interpreted as described for stream_init().
*
- * When '*streamp' is closed, then 'unlink_path' (if nonnull) will be passed to
- * fatal_signal_unlink_file_now() and then freed with free().
- *
* Returns 0 if successful, otherwise a positive errno value. (The current
* implementation never fails.) */
int
new_fd_stream(const char *name, int fd, int connect_status,
- char *unlink_path, struct stream **streamp)
+ struct stream **streamp)
{
struct stream_fd *s;
s = xmalloc(sizeof *s);
stream_init(&s->stream, &stream_fd_class, connect_status, name);
s->fd = fd;
- s->unlink_path = unlink_path;
*streamp = &s->stream;
return 0;
}
{
struct stream_fd *s = stream_fd_cast(stream);
close(s->fd);
- maybe_unlink_and_free(s->unlink_path);
free(s);
}
/*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
struct sockaddr;
int new_fd_stream(const char *name, int fd, int connect_status,
- char *unlink_path, struct stream **streamp);
+ struct stream **streamp);
int new_fd_pstream(const char *name, int fd,
int (*accept_cb)(int fd, const struct sockaddr *,
size_t sa_len, struct stream **),
/*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return errno;
}
- retval = new_fd_stream(name, fd, connect_status, NULL, streamp);
+ retval = new_fd_stream(name, fd, connect_status, streamp);
if (!retval) {
struct stream *stream = *streamp;
stream_set_remote_ip(stream, remote->sin_addr.s_addr);
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/* Active UNIX socket. */
-/* Number of unix sockets created so far, to ensure binding path uniqueness. */
-static int n_unix_sockets;
-
static int
unix_open(const char *name, char *suffix, struct stream **streamp)
{
const char *connect_path = suffix;
- char *bind_path;
int fd;
- bind_path = xasprintf("/tmp/stream-unix.%ld.%d",
- (long int) getpid(), n_unix_sockets++);
- fd = make_unix_socket(SOCK_STREAM, true, false, bind_path, connect_path);
+ fd = make_unix_socket(SOCK_STREAM, true, false, NULL, connect_path);
if (fd < 0) {
- VLOG_ERR("%s: connection to %s failed: %s",
- bind_path, connect_path, strerror(-fd));
- free(bind_path);
+ VLOG_ERR("%s: connection failed (%s)", connect_path, strerror(-fd));
return -fd;
}
- return new_fd_stream(name, fd, check_connection_completion(fd),
- bind_path, streamp);
+ return new_fd_stream(name, fd, check_connection_completion(fd), streamp);
}
const struct stream_class unix_stream_class = {
} else {
strcpy(name, "unix");
}
- return new_fd_stream(name, fd, 0, NULL, streamp);
+ return new_fd_stream(name, fd, 0, streamp);
}
const struct pstream_class punix_pstream_class = {
-# Copyright (c) 2010, 2011 Nicira Networks
+# Copyright (c) 2010, 2011, 2012 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
class Stream(object):
"""Bidirectional byte stream. Currently only Unix domain sockets
are implemented."""
- n_unix_sockets = 0
# States.
__S_CONNECTING = 0
False."""
return name.startswith("unix:")
- def __init__(self, socket, name, bind_path, status):
+ def __init__(self, socket, name, status):
self.socket = socket
self.name = name
- self.bind_path = bind_path
if status == errno.EAGAIN:
self.state = Stream.__S_CONNECTING
elif status == 0:
if not Stream.is_valid_name(name):
return errno.EAFNOSUPPORT, None
- Stream.n_unix_sockets += 1
- bind_path = "/tmp/stream-unix.%d.%d" % (os.getpid(),
- Stream.n_unix_sockets)
connect_path = name[5:]
error, sock = ovs.socket_util.make_unix_socket(socket.SOCK_STREAM,
- True, bind_path,
+ True, None,
connect_path)
if error:
return error, None
else:
status = ovs.socket_util.check_connection_completion(sock)
- return 0, Stream(sock, name, bind_path, status)
+ return 0, Stream(sock, name, status)
@staticmethod
def open_block((error, stream)):
def close(self):
self.socket.close()
- if self.bind_path is not None:
- ovs.fatal_signal.unlink_file_now(self.bind_path)
- self.bind_path = None
def __scs_connecting(self):
retval = ovs.socket_util.check_connection_completion(self.socket)
try:
sock, addr = self.socket.accept()
ovs.socket_util.set_nonblocking(sock)
- return 0, Stream(sock, "unix:%s" % addr, None, 0)
+ return 0, Stream(sock, "unix:%s" % addr, 0)
except socket.error, e:
error = ovs.socket_util.get_exception_errno(e)
if error != errno.EAGAIN: