Merge "Fix resource leak issues, file not close case"
This commit is contained in:
commit
ebb9dae417
|
@ -784,6 +784,7 @@ string get_shadow_signature ( char * shadowfile , const char * username,
|
||||||
int ret = snprintf(shadowinfo, infolen, "%s", shadowEntry);
|
int ret = snprintf(shadowinfo, infolen, "%s", shadowEntry);
|
||||||
if (ret >= (int)infolen)
|
if (ret >= (int)infolen)
|
||||||
{
|
{
|
||||||
|
fclose(file_ptr);
|
||||||
elog("insufficient space in shadow buffer(%d) for %d bytes\n",
|
elog("insufficient space in shadow buffer(%d) for %d bytes\n",
|
||||||
(int)infolen, ret);
|
(int)infolen, ret);
|
||||||
return ( "" );
|
return ( "" );
|
||||||
|
|
|
@ -328,8 +328,8 @@ int add_rmon_client ( const char * process_name_ptr, int port , const char * reg
|
||||||
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
|
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
|
||||||
// release write lock
|
// release write lock
|
||||||
flock(fileno(pFile), LOCK_UN);
|
flock(fileno(pFile), LOCK_UN);
|
||||||
fclose(pFile);
|
|
||||||
}
|
}
|
||||||
|
fclose(pFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -442,8 +442,8 @@ int remove_rmon_client( const char * process_name_ptr, int socket )
|
||||||
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
|
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
|
||||||
// release the lock
|
// release the lock
|
||||||
flock(fileno(pFile), LOCK_UN);
|
flock(fileno(pFile), LOCK_UN);
|
||||||
fclose(pFile);
|
|
||||||
}
|
}
|
||||||
|
fclose(pFile);
|
||||||
} else {
|
} else {
|
||||||
syslog (LOG_ERR, "Failed to open '%s'\n",
|
syslog (LOG_ERR, "Failed to open '%s'\n",
|
||||||
RMON_API_DEREG_DIR );
|
RMON_API_DEREG_DIR );
|
||||||
|
|
Loading…
Reference in New Issue