it, and map that to close() on Unix.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.99 2003/04/17 22:26:01 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.100 2003/04/25 01:24:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
ident_user);
}
}
- close(sock_fd);
+ closesocket(sock_fd);
}
}
return ident_return;
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.151 2003/04/22 00:08:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.152 2003/04/25 01:24:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (MyProcPort != NULL)
{
secure_close(MyProcPort);
- close(MyProcPort->sock);
+ closesocket(MyProcPort->sock);
/* make sure any subsequent attempts to do I/O fail cleanly */
MyProcPort->sock = -1;
}
snprintf(portNumberStr, sizeof(portNumberStr), "%d", portNumber);
service = portNumberStr;
}
-
+
ret = getaddrinfo2(hostName, service, &hint, &addrs);
if (ret || addrs == NULL)
{
void
StreamClose(int sock)
{
- close(sock);
+ closesocket(sock);
}
/*
*
* Copyright (c) 2001, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.32 2003/03/20 03:34:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.33 2003/04/25 01:24:00 momjian Exp $
* ----------
*/
#include "postgres.h"
startup_failed:
if (pgStatSock >= 0)
- close(pgStatSock);
+ closesocket(pgStatSock);
pgStatSock = -1;
/* Adjust GUC variables to suppress useless activity */
pgstat_close_sockets(void)
{
if (pgStatPmPipe[0] >= 0)
- close(pgStatPmPipe[0]);
+ closesocket(pgStatPmPipe[0]);
pgStatPmPipe[0] = -1;
if (pgStatPmPipe[1] >= 0)
- close(pgStatPmPipe[1]);
+ closesocket(pgStatPmPipe[1]);
pgStatPmPipe[1] = -1;
}
* Close the writing end of the postmaster pipe, so we'll see it
* closing when the postmaster terminates and can terminate as well.
*/
- close(pgStatPmPipe[1]);
+ closesocket(pgStatPmPipe[1]);
pgStatPmPipe[1] = -1;
/*
case 0:
/* child becomes collector process */
- close(pgStatPipe[1]);
- close(pgStatSock);
+ closesocket(pgStatPipe[1]);
+ closesocket(pgStatSock);
break;
default:
/* parent becomes buffer process */
- close(pgStatPipe[0]);
+ closesocket(pgStatPipe[0]);
pgstat_recvbuffer();
exit(0);
}
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: c.h,v 1.139 2003/04/22 02:18:09 momjian Exp $
+ * $Id: c.h,v 1.140 2003/04/25 01:24:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#define unlink(from, to) pgunlink(from, to)
#endif
+/*
+ * Win32 requires a special close for sockets and pipes, while on Unix
+ * close() does them all.
+ */
+#ifndef WIN32
+#define closesocket close
+#endif
/* These are for things that are one way on Unix and another on NT */
#define NULL_DEV "/dev/null"
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.235 2003/04/24 21:16:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.236 2003/04/25 01:24:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* ignore connect() failure if we have more addrs to try */
if (addr_cur->ai_next != NULL)
{
- close(conn->sock);
+ closesocket(conn->sock);
conn->sock = -1;
continue;
}
if (conn->Pfdebug)
fprintf(conn->Pfdebug, "Postmaster reports error, attempting fallback to pre-7.0.\n");
pqsecure_close(conn);
-#ifdef WIN32
closesocket(conn->sock);
-#else
- close(conn->sock);
-#endif
conn->sock = -1;
conn->allow_ssl_try = FALSE;
return connectDBStart(conn);
if (conn->sock >= 0)
{
pqsecure_close(conn);
-#ifdef WIN32
closesocket(conn->sock);
-#else
- close(conn->sock);
-#endif
conn->sock = -1;
}
conn->status = CONNECTION_BAD;
if (conn->sock >= 0)
{
pqsecure_close(conn);
-#ifdef WIN32
closesocket(conn->sock);
-#else
- close(conn->sock);
-#endif
}
if (conn->pghost)
free(conn->pghost);
if (conn->sock >= 0)
{
pqsecure_close(conn);
-#ifdef WIN32
closesocket(conn->sock);
-#else
- close(conn->sock);
-#endif
}
conn->sock = -1;
conn->status = CONNECTION_BAD; /* Well, not really _bad_ - just
}
/* Sent it, done */
-#ifdef WIN32
closesocket(tmpsock);
+#ifdef WIN32
WSASetLastError(save_errno);
#else
- close(tmpsock);
errno = save_errno;
#endif
conn->errorMessage.len = strlen(conn->errorMessage.data);
if (tmpsock >= 0)
{
-#ifdef WIN32
closesocket(tmpsock);
+#ifdef WIN32
WSASetLastError(save_errno);
#else
- close(tmpsock);
errno = save_errno;
#endif
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.131 2003/04/24 21:16:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.132 2003/04/25 01:24:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
id, msgLength);
conn->status = CONNECTION_BAD; /* No more connection to backend */
pqsecure_close(conn);
-#ifdef WIN32
closesocket(conn->sock);
-#else
- close(conn->sock);
-#endif
conn->sock = -1;
}
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.90 2003/04/22 00:08:07 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.91 2003/04/25 01:24:00 momjian Exp $
*
*-------------------------------------------------------------------------
*/
"\tbefore or while processing the request.\n"));
conn->status = CONNECTION_BAD; /* No more connection to backend */
pqsecure_close(conn);
-#ifdef WIN32
closesocket(conn->sock);
-#else
- close(conn->sock);
-#endif
conn->sock = -1;
return -1;
n = j; /* never used before this assignment */
}
if (n)
- {
+ {
/* allocate buffer */
if (!(buffer = malloc(MAX_BUFFER_SIZE)))
- {
+ {
PyErr_SetString(PyExc_MemoryError,
"can't allocate insert buffer.");
return NULL;
getsubitem = PyTuple_GetItem;
else
getsubitem = PyList_GetItem;
-
+
/* builds insert line */
bufpt=buffer;
bufsiz = MAX_BUFFER_SIZE - 1;
{
*bufpt++ = '\t'; --bufsiz;
}
-
+
if (bufsiz <= 0)
{
free(buffer);
/* sends data */
PQputline(self->cnx, buffer);
}
-
+
/* ends query */
PQputline(self->cnx, "\\.\n");
PQendcopy(self->cnx);