forked from mirrors/linphone-iphone
atomically sync the lpconfig on disk
This commit is contained in:
parent
a7d81a117d
commit
08539a0895
3 changed files with 9 additions and 2 deletions
|
|
@ -77,6 +77,7 @@ struct _LpConfig{
|
|||
int refcnt;
|
||||
FILE *file;
|
||||
char *filename;
|
||||
char *tmpfilename;
|
||||
MSList *sections;
|
||||
int modified;
|
||||
int readonly;
|
||||
|
|
@ -349,6 +350,7 @@ LpConfig *lp_config_new_with_factory(const char *config_filename, const char *fa
|
|||
if (config_filename!=NULL){
|
||||
ms_message("Using (r/w) config information from %s", config_filename);
|
||||
lpconfig->filename=ortp_strdup(config_filename);
|
||||
lpconfig->tmpfilename=ortp_strdup_printf("%s.tmp",config_filename);
|
||||
lpconfig->file=fopen(config_filename,"r+");
|
||||
if (lpconfig->file!=NULL){
|
||||
lp_config_parse(lpconfig,lpconfig->file);
|
||||
|
|
@ -583,7 +585,7 @@ int lp_config_sync(LpConfig *lpconfig){
|
|||
/* don't create group/world-accessible files */
|
||||
(void) umask(S_IRWXG | S_IRWXO);
|
||||
#endif
|
||||
file=fopen(lpconfig->filename,"w");
|
||||
file=fopen(lpconfig->tmpfilename,"w");
|
||||
if (file==NULL){
|
||||
ms_warning("Could not write %s ! Maybe it is read-only. Configuration will not be saved.",lpconfig->filename);
|
||||
lpconfig->readonly=1;
|
||||
|
|
@ -591,6 +593,9 @@ int lp_config_sync(LpConfig *lpconfig){
|
|||
}
|
||||
ms_list_for_each2(lpconfig->sections,(void (*)(void *,void*))lp_section_write,(void *)file);
|
||||
fclose(file);
|
||||
if (rename(lpconfig->tmpfilename,lpconfig->filename)!=0){
|
||||
ms_error("Cannot rename %s into %s: %s",lpconfig->tmpfilename,lpconfig->filename,strerror(errno));
|
||||
}
|
||||
lpconfig->modified=0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -966,6 +966,8 @@ unsigned int linphone_core_get_audio_features(LinphoneCore *lc){
|
|||
else if (strcasecmp(name,"DTMF")==0) ret|=AUDIO_STREAM_FEATURE_DTMF;
|
||||
else if (strcasecmp(name,"DTMF_ECHO")==0) ret|=AUDIO_STREAM_FEATURE_DTMF_ECHO;
|
||||
else if (strcasecmp(name,"MIXED_RECORDING")==0) ret|=AUDIO_STREAM_FEATURE_MIXED_RECORDING;
|
||||
else if (strcasecmp(name,"LOCAL_PLAYING")==0) ret|=AUDIO_STREAM_FEATURE_LOCAL_PLAYING;
|
||||
else if (strcasecmp(name,"REMOTE_PLAYING")==0) ret|=AUDIO_STREAM_FEATURE_REMOTE_PLAYING;
|
||||
else if (strcasecmp(name,"ALL")==0) ret|=AUDIO_STREAM_FEATURE_ALL;
|
||||
else if (strcasecmp(name,"NONE")==0) ret=0;
|
||||
else ms_error("Unsupported audio feature %s requested in config file.",name);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit c45dca7bedea220fe3bc718b89bd36a21c97fa2f
|
||||
Subproject commit 2054fd60911b585458b62d52092894a5d1b59503
|
||||
Loading…
Add table
Reference in a new issue