summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1bada7a)
get_null_fd() is only called from daemon.c.
It does not need thread safety features anymore as
it is called either through daemonize_start() or
indirectly through daemonize_complete() once.
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
set_subprogram_name("");
}
set_subprogram_name("");
}
+/* Returns a readable and writable fd for /dev/null, if successful, otherwise
+ * a negative errno value. The caller must not close the returned fd (because
+ * the same fd will be handed out to subsequent callers). */
+static int
+get_null_fd(void)
+{
+ static int null_fd;
+
+ if (!null_fd) {
+ null_fd = open("/dev/null", O_RDWR);
+ if (null_fd < 0) {
+ int error = errno;
+ VLOG_ERR("could not open /dev/null: %s", ovs_strerror(error));
+ null_fd = -error;
+ }
+ }
+
+ return null_fd;
+}
+
/* Close standard file descriptors (except any that the client has requested we
* leave open by calling daemon_save_fd()). If we're started from e.g. an SSH
* session, then this keeps us from holding that session open artificially. */
/* Close standard file descriptors (except any that the client has requested we
* leave open by calling daemon_save_fd()). If we're started from e.g. an SSH
* session, then this keeps us from holding that session open artificially. */
-/* Returns a readable and writable fd for /dev/null, if successful, otherwise
- * a negative errno value. The caller must not close the returned fd (because
- * the same fd will be handed out to subsequent callers). */
-int
-get_null_fd(void)
-{
- static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
- static int null_fd;
-
- if (ovsthread_once_start(&once)) {
- null_fd = open("/dev/null", O_RDWR);
- if (null_fd < 0) {
- int error = errno;
- VLOG_ERR("could not open /dev/null: %s", ovs_strerror(error));
- null_fd = -error;
- }
- ovsthread_once_done(&once);
- }
-
- return null_fd;
-}
-
int
read_fully(int fd, void *p_, size_t size, size_t *bytes_read)
{
int
read_fully(int fd, void *p_, size_t size, size_t *bytes_read)
{
int get_unix_name_len(socklen_t sun_len);
#endif
ovs_be32 guess_netmask(ovs_be32 ip);
int get_unix_name_len(socklen_t sun_len);
#endif
ovs_be32 guess_netmask(ovs_be32 ip);
bool inet_parse_active(const char *target, uint16_t default_port,
struct sockaddr_storage *ssp);
bool inet_parse_active(const char *target, uint16_t default_port,
struct sockaddr_storage *ssp);