Copyright 2004-2006 Lennart Poettering
Copyright 2004 Joe Marcus Clarke
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
return ret;
}
+/** Platform independent read function. Necessary since not all
+ * systems treat all file descriptors equal. */
+int pa_close(int fd)
+{
+#ifdef OS_IS_WIN32
+ int ret;
+
+ ret = closesocket(fd);
+ if (ret == 0)
+ return 0;
+
+ if (WSAGetLastError() != WSAENOTSOCK) {
+ errno = WSAGetLastError();
+ return ret;
+ }
+#endif
+
+ return close(fd);
+}
+
/* Print a warning messages in case that the given signal is not
* blocked or trapped */
void pa_check_signal_is_blocked(int sig) {
This file is part of PulseAudio.
Copyright 2004-2006 Lennart Poettering
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
ssize_t pa_loop_read(int fd, void*data, size_t size, int *type);
ssize_t pa_loop_write(int fd, const void*data, size_t size, int *type);
+int pa_close(int fd);
+
void pa_check_signal_is_blocked(int sig);
char *pa_sprintf_malloc(const char *format, ...) PA_GCC_PRINTF_ATTR(1,2);
This file is part of PulseAudio.
Copyright 2004-2006 Lennart Poettering
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
if (!io->no_close) {
if (io->ifd >= 0)
-
- close(io->ifd);
+ pa_close(io->ifd);
if (io->ofd >= 0 && io->ofd != io->ifd)
- close(io->ofd);
+ pa_close(io->ofd);
}
pa_xfree(io);
/***
This file is part of PulseAudio.
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
if ((addr.sin_port != peer.sin_port) || (addr.sin_addr.s_addr != peer.sin_addr.s_addr))
goto error;
- close(listener);
+ pa_close(listener);
return 0;
error:
if (listener >= 0)
- close(listener);
+ pa_close(listener);
if (filedes[0] >= 0)
- close(filedes[0]);
+ pa_close(filedes[0]);
if (filedes[1] >= 0)
- close(filedes[0]);
+ pa_close(filedes[0]);
return -1;
}
This file is part of PulseAudio.
Copyright 2004-2006 Lennart Poettering
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
finish:
if (!io && c->fd >= 0)
- close(c->fd);
+ pa_close(c->fd);
c->fd = -1;
free_events(c);
free_events(c);
if (c->fd >= 0)
- close(c->fd);
+ pa_close(c->fd);
#ifdef HAVE_LIBASYNCNS
if (c->asyncns_query)
assert(c);
if (c->fd >= 0) {
- close(c->fd);
+ pa_close(c->fd);
c->fd = -1;
}
This file is part of PulseAudio.
Copyright 2004-2006 Lennart Poettering
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
pa_fd_set_cloexec(nfd, 1);
if (!s->on_connection) {
- close(nfd);
+ pa_close(nfd);
goto finish;
}
fromhost(&req);
if (!hosts_access(&req)) {
pa_log_warn("TCP connection refused by tcpwrap.");
- close(nfd);
+ pa_close(nfd);
goto finish;
}
fail:
if (fd >= 0)
- close(fd);
+ pa_close(fd);
return NULL;
}
fail:
if (fd >= 0)
- close(fd);
+ pa_close(fd);
return NULL;
}
fail:
if (fd >= 0)
- close(fd);
+ pa_close(fd);
return NULL;
}
pa_xfree(s->filename);
}
- close(s->fd);
+ pa_close(s->fd);
pa_xfree(s->tcpwrap_service);
Copyright 2004-2006 Lennart Poettering
Copyright 2004 Joe Marcus Clarke
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
finish:
if (fd >= 0)
- close(fd);
+ pa_close(fd);
return ret;
}