@@ -70,7 +70,7 @@ static void DisconnectDatabase(ParallelSlot *slot);
7070
7171static int select_loop (int maxFd , fd_set * workerset , bool * aborting );
7272
73- static void init_slot (ParallelSlot * slot , PGconn * conn );
73+ static void init_slot (ParallelSlot * slot , PGconn * conn , const char * progname );
7474
7575static void help (const char * progname );
7676
@@ -421,14 +421,14 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
421421 * array contains the connection.
422422 */
423423 slots = (ParallelSlot * ) pg_malloc (sizeof (ParallelSlot ) * concurrentCons );
424- init_slot (slots , conn );
424+ init_slot (slots , conn , progname );
425425 if (parallel )
426426 {
427427 for (i = 1 ; i < concurrentCons ; i ++ )
428428 {
429429 conn = connectDatabase (dbname , host , port , username , prompt_password ,
430430 progname , false, true);
431- init_slot (slots + i , conn );
431+ init_slot (slots + i , conn , progname );
432432 }
433433 }
434434
@@ -917,11 +917,18 @@ select_loop(int maxFd, fd_set *workerset, bool *aborting)
917917}
918918
919919static void
920- init_slot (ParallelSlot * slot , PGconn * conn )
920+ init_slot (ParallelSlot * slot , PGconn * conn , const char * progname )
921921{
922922 slot -> connection = conn ;
923923 slot -> isFree = true;
924924 slot -> sock = PQsocket (conn );
925+
926+ if (slot -> sock < 0 )
927+ {
928+ fprintf (stderr , _ ("%s: invalid socket: %s" ), progname ,
929+ PQerrorMessage (conn ));
930+ exit (1 );
931+ }
925932}
926933
927934static void
0 commit comments