X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fvconn-unix.c;h=d2b5a0f4060a831d53cd14cefc6d08683ed98849;hb=67a4917b07031b387beafaedce413b4207214059;hp=e2b6f7a3704bb79a1bb00d5586a9890c30ad4a84;hpb=85ab0a021523e51435539af0e6a138c73c9846a2;p=openvswitch diff --git a/lib/vconn-unix.c b/lib/vconn-unix.c index e2b6f7a3..d2b5a0f4 100644 --- a/lib/vconn-unix.c +++ b/lib/vconn-unix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Nicira Networks. + * Copyright (c) 2008, 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,20 +47,21 @@ static int unix_open(const char *name, char *suffix, struct vconn **vconnp) { const char *connect_path = suffix; - char bind_path[128]; + char *bind_path; int fd; - sprintf(bind_path, "/tmp/vconn-unix.%ld.%d", - (long int) getpid(), n_unix_sockets++); + bind_path = xasprintf("/tmp/vconn-unix.%ld.%d", + (long int) getpid(), n_unix_sockets++); fd = make_unix_socket(SOCK_STREAM, true, false, bind_path, connect_path); if (fd < 0) { VLOG_ERR("%s: connection to %s failed: %s", bind_path, connect_path, strerror(-fd)); + free(bind_path); return -fd; } return new_stream_vconn(name, fd, check_connection_completion(fd), - vconnp); + bind_path, vconnp); } struct vconn_class unix_vconn_class = { @@ -79,7 +80,7 @@ static int punix_accept(int fd, const struct sockaddr *sa, size_t sa_len, struct vconn **vconnp); static int -punix_open(const char *name UNUSED, char *suffix, struct pvconn **pvconnp) +punix_open(const char *name OVS_UNUSED, char *suffix, struct pvconn **pvconnp) { int fd, error; @@ -102,7 +103,8 @@ punix_open(const char *name UNUSED, char *suffix, struct pvconn **pvconnp) return error; } - return new_pstream_pvconn("punix", fd, punix_accept, pvconnp); + return new_pstream_pvconn("punix", fd, punix_accept, + xstrdup(suffix), pvconnp); } static int @@ -118,7 +120,7 @@ punix_accept(int fd, const struct sockaddr *sa, size_t sa_len, } else { strcpy(name, "unix"); } - return new_stream_vconn(name, fd, 0, vconnp); + return new_stream_vconn(name, fd, 0, NULL, vconnp); } struct pvconn_class punix_pvconn_class = {