Skip to content

Commit bac40d7

Browse files
committed
Fix the race when reloading rpm database
Signed-off-by: Radovan Sroka <rsroka@redhat.com>
1 parent f76484b commit bac40d7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/library/rpm-backend.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ static rpmdbMatchIterator mi = NULL;
136136

137137
static int init_rpm(void)
138138
{
139+
ongoing_rpm_operation = 1;
139140
return rpmReadConfigFiles ((const char *)NULL, (const char *)NULL);
140141
}
141142

@@ -261,7 +262,7 @@ struct _hash_record {
261262
extern unsigned int debug_mode;
262263
static int rpm_load_list(const conf_t *conf)
263264
{
264-
int rc;
265+
int rc = 0;
265266
unsigned int msg_count = 0;
266267
unsigned int tsource = SRC_RPM;
267268

@@ -271,12 +272,10 @@ static int rpm_load_list(const conf_t *conf)
271272
// hash table
272273
struct _hash_record *hashtable = NULL;
273274

274-
ongoing_rpm_operation = 1;
275-
276275
msg(LOG_INFO, "Loading rpmdb backend");
277276
if ((rc = init_rpm())) {
278277
msg(LOG_ERR, "init_rpm() failed (%d)", rc);
279-
return rc;
278+
goto error;
280279
}
281280

282281
// Loop across the rpm database
@@ -362,6 +361,7 @@ static int rpm_load_list(const conf_t *conf)
362361

363362
close_rpm();
364363

364+
error:
365365
ongoing_rpm_operation = 0;
366366
close_fds_in_buffer();
367367

@@ -373,7 +373,7 @@ static int rpm_load_list(const conf_t *conf)
373373
free((void*)item);
374374
}
375375

376-
return 0;
376+
return rc;
377377
}
378378

379379
static int rpm_init_backend(void)

0 commit comments

Comments
 (0)