@@ -70,7 +70,7 @@ static void DisconnectDatabase(ParallelSlot *slot);
70
70
71
71
static int select_loop (int maxFd ,fd_set * workerset ,bool * aborting );
72
72
73
- static void init_slot (ParallelSlot * slot ,PGconn * conn );
73
+ static void init_slot (ParallelSlot * slot ,PGconn * conn , const char * progname );
74
74
75
75
static void help (const char * progname );
76
76
@@ -421,14 +421,14 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
421
421
* array contains the connection.
422
422
*/
423
423
slots = (ParallelSlot * )pg_malloc (sizeof (ParallelSlot )* concurrentCons );
424
- init_slot (slots ,conn );
424
+ init_slot (slots ,conn , progname );
425
425
if (parallel )
426
426
{
427
427
for (i = 1 ;i < concurrentCons ;i ++ )
428
428
{
429
429
conn = connectDatabase (dbname ,host ,port ,username ,prompt_password ,
430
430
progname , false, true);
431
- init_slot (slots + i ,conn );
431
+ init_slot (slots + i ,conn , progname );
432
432
}
433
433
}
434
434
@@ -917,11 +917,18 @@ select_loop(int maxFd, fd_set *workerset, bool *aborting)
917
917
}
918
918
919
919
static void
920
- init_slot (ParallelSlot * slot ,PGconn * conn )
920
+ init_slot (ParallelSlot * slot ,PGconn * conn , const char * progname )
921
921
{
922
922
slot -> connection = conn ;
923
923
slot -> isFree = true;
924
924
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
+ }
925
932
}
926
933
927
934
static void