diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
commit | f7d30133221896638f7bf4f66c504255c4b14f48 (patch) | |
tree | 5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/pr/src/md/unix/uxshm.c | |
parent | 26b297510a11758727438df4669357a2a2bc42ce (diff) | |
download | UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.lz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.xz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.zip |
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/pr/src/md/unix/uxshm.c')
-rw-r--r-- | nsprpub/pr/src/md/unix/uxshm.c | 243 |
1 files changed, 115 insertions, 128 deletions
diff --git a/nsprpub/pr/src/md/unix/uxshm.c b/nsprpub/pr/src/md/unix/uxshm.c index 54e68191c..29a6030f4 100644 --- a/nsprpub/pr/src/md/unix/uxshm.c +++ b/nsprpub/pr/src/md/unix/uxshm.c @@ -14,7 +14,7 @@ #include <prshm.h> #include <prerr.h> #include <prmem.h> -#include "primpl.h" +#include "primpl.h" #include <fcntl.h> extern PRLogModuleInfo *_pr_shm_lm; @@ -36,7 +36,7 @@ extern PRLogModuleInfo *_pr_shm_lm; #define _MD_CLOSE_SHARED_MEMORY _MD_CloseSharedMemory #define _MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory -extern PRSharedMemory * _MD_OpenSharedMemory( +extern PRSharedMemory * _MD_OpenSharedMemory( const char *name, PRSize size, PRIntn flags, @@ -52,16 +52,16 @@ extern PRSharedMemory * _MD_OpenSharedMemory( if ( PR_FAILURE == rc ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); return( NULL ); } shm = PR_NEWZAP( PRSharedMemory ); - if ( NULL == shm ) + if ( NULL == shm ) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 ); - PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New PRSharedMemory out of memory")); + PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New PRSharedMemory out of memory")); return( NULL ); } @@ -69,7 +69,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory( if ( NULL == shm->ipcname ) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 ); - PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New shm->ipcname out of memory")); + PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New shm->ipcname out of memory")); PR_DELETE( shm ); return( NULL ); } @@ -89,7 +89,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory( PR_FREEIF( shm->ipcname ); PR_DELETE( shm ); return( NULL ); - } + } if ( close(osfd) == -1 ) { _PR_MD_MAP_CLOSE_ERROR( errno ); PR_FREEIF( shm->ipcname ); @@ -104,8 +104,8 @@ extern PRSharedMemory * _MD_OpenSharedMemory( { rc = PR_FAILURE; _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): ftok() failed on name: %s", shm->ipcname)); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): ftok() failed on name: %s", shm->ipcname)); PR_FREEIF( shm->ipcname ); PR_DELETE( shm ); return( NULL ); @@ -119,19 +119,19 @@ extern PRSharedMemory * _MD_OpenSharedMemory( } if ((errno == EEXIST) && (flags & PR_SHM_EXCL)) { PR_SetError( PR_FILE_EXISTS_ERROR, errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): shmget() exclusive failed, errno: %d", errno)); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): shmget() exclusive failed, errno: %d", errno)); PR_FREEIF(shm->ipcname); PR_DELETE(shm); return(NULL); } - } + } shm->id = shmget( key, shm->size, shm->mode ); if ( -1 == shm->id ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): shmget() failed, errno: %d", errno)); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): shmget() failed, errno: %d", errno)); PR_FREEIF(shm->ipcname); PR_DELETE(shm); return(NULL); @@ -153,14 +153,14 @@ extern void * _MD_AttachSharedMemory( PRSharedMemory *shm, PRIntn flags ) if ( (void*)-1 == addr ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_AttachSharedMemory(): shmat() failed on name: %s, OsError: %d", - shm->ipcname, PR_GetOSError() )); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_AttachSharedMemory(): shmat() failed on name: %s, OsError: %d", + shm->ipcname, PR_GetOSError() )); addr = NULL; } return addr; -} +} extern PRStatus _MD_DetachSharedMemory( PRSharedMemory *shm, void *addr ) { @@ -174,12 +174,12 @@ extern PRStatus _MD_DetachSharedMemory( PRSharedMemory *shm, void *addr ) { rc = PR_FAILURE; _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DetachSharedMemory(): shmdt() failed on name: %s", shm->ipcname )); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DetachSharedMemory(): shmdt() failed on name: %s", shm->ipcname )); } return rc; -} +} extern PRStatus _MD_CloseSharedMemory( PRSharedMemory *shm ) { @@ -189,7 +189,7 @@ extern PRStatus _MD_CloseSharedMemory( PRSharedMemory *shm ) PR_DELETE(shm); return PR_SUCCESS; -} +} extern PRStatus _MD_DeleteSharedMemory( const char *name ) { @@ -202,19 +202,19 @@ extern PRStatus _MD_DeleteSharedMemory( const char *name ) rc = _PR_MakeNativeIPCName( name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm ); if ( PR_FAILURE == rc ) { - PR_SetError( PR_UNKNOWN_ERROR , errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DeleteSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); + PR_SetError( PR_UNKNOWN_ERROR, errno ); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DeleteSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); return(PR_FAILURE); } - /* create the file first */ + /* create the file first */ { int osfd = open( ipcname, (O_RDWR | O_CREAT), 0666 ); if ( -1 == osfd ) { _PR_MD_MAP_OPEN_ERROR( errno ); return( PR_FAILURE ); - } + } if ( close(osfd) == -1 ) { _PR_MD_MAP_CLOSE_ERROR( errno ); return( PR_FAILURE ); @@ -227,20 +227,15 @@ extern PRStatus _MD_DeleteSharedMemory( const char *name ) { rc = PR_FAILURE; _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DeleteSharedMemory(): ftok() failed on name: %s", ipcname)); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DeleteSharedMemory(): ftok() failed on name: %s", ipcname)); } -#ifdef SYMBIAN - /* In Symbian OS the system imposed minimum is 1 byte, instead of ZERO */ - id = shmget( key, 1, 0 ); -#else id = shmget( key, 0, 0 ); -#endif if ( -1 == id ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DeleteSharedMemory(): shmget() failed, errno: %d", errno)); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DeleteSharedMemory(): shmget() failed, errno: %d", errno)); return(PR_FAILURE); } @@ -248,16 +243,16 @@ extern PRStatus _MD_DeleteSharedMemory( const char *name ) if ( -1 == urc ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DeleteSharedMemory(): shmctl() failed on name: %s", ipcname )); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DeleteSharedMemory(): shmctl() failed on name: %s", ipcname )); return(PR_FAILURE); } urc = unlink( ipcname ); if ( -1 == urc ) { _PR_MD_MAP_UNLINK_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DeleteSharedMemory(): unlink() failed: %s", ipcname )); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DeleteSharedMemory(): unlink() failed: %s", ipcname )); return(PR_FAILURE); } @@ -280,7 +275,7 @@ struct _MDSharedMemory { int handle; }; -extern PRSharedMemory * _MD_OpenSharedMemory( +extern PRSharedMemory * _MD_OpenSharedMemory( const char *name, PRSize size, PRIntn flags, @@ -295,17 +290,17 @@ extern PRSharedMemory * _MD_OpenSharedMemory( rc = _PR_MakeNativeIPCName( name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm ); if ( PR_FAILURE == rc ) { - PR_SetError( PR_UNKNOWN_ERROR , errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); + PR_SetError( PR_UNKNOWN_ERROR, errno ); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); return( NULL ); } shm = PR_NEWZAP( PRSharedMemory ); - if ( NULL == shm ) + if ( NULL == shm ) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 ); - PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New PRSharedMemory out of memory")); + PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New PRSharedMemory out of memory")); return( NULL ); } @@ -313,13 +308,13 @@ extern PRSharedMemory * _MD_OpenSharedMemory( if ( NULL == shm->ipcname ) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 ); - PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New shm->ipcname out of memory")); + PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New shm->ipcname out of memory")); return( NULL ); } /* copy args to struct */ strcpy( shm->ipcname, ipcname ); - shm->size = size; + shm->size = size; shm->mode = mode; shm->flags = flags; shm->ident = _PR_SHM_IDENT; @@ -329,9 +324,10 @@ extern PRSharedMemory * _MD_OpenSharedMemory( */ if ( flags & PR_SHM_CREATE ) { int oflag = (O_CREAT | O_RDWR); - - if ( flags & PR_SHM_EXCL ) + + if ( flags & PR_SHM_EXCL ) { oflag |= O_EXCL; + } shm->id = shm_open( shm->ipcname, oflag, shm->mode ); } else { shm->id = shm_open( shm->ipcname, O_RDWR, shm->mode ); @@ -339,9 +335,9 @@ extern PRSharedMemory * _MD_OpenSharedMemory( if ( -1 == shm->id ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): shm_open failed: %s, OSError: %d", - shm->ipcname, PR_GetOSError())); + PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): shm_open failed: %s, OSError: %d", + shm->ipcname, PR_GetOSError())); PR_DELETE( shm->ipcname ); PR_DELETE( shm ); return(NULL); @@ -350,8 +346,8 @@ extern PRSharedMemory * _MD_OpenSharedMemory( end = ftruncate( shm->id, shm->size ); if ( -1 == end ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): ftruncate failed, OSError: %d", + PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): ftruncate failed, OSError: %d", PR_GetOSError())); PR_DELETE( shm->ipcname ); PR_DELETE( shm ); @@ -368,24 +364,25 @@ extern void * _MD_AttachSharedMemory( PRSharedMemory *shm, PRIntn flags ) PR_ASSERT( shm->ident == _PR_SHM_IDENT ); - if ( PR_SHM_READONLY == flags) + if ( PR_SHM_READONLY == flags) { prot ^= PROT_WRITE; + } addr = mmap( (void*)0, shm->size, prot, MAP_SHARED, shm->id, 0 ); if ((void*)-1 == addr ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_AttachSharedMemory(): mmap failed: %s, errno: %d", - shm->ipcname, PR_GetOSError())); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_AttachSharedMemory(): mmap failed: %s, errno: %d", + shm->ipcname, PR_GetOSError())); addr = NULL; } else { - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_AttachSharedMemory(): name: %s, attached at: %p", shm->ipcname, addr)); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_AttachSharedMemory(): name: %s, attached at: %p", shm->ipcname, addr)); } - + return addr; -} +} extern PRStatus _MD_DetachSharedMemory( PRSharedMemory *shm, void *addr ) { @@ -399,30 +396,30 @@ extern PRStatus _MD_DetachSharedMemory( PRSharedMemory *shm, void *addr ) { rc = PR_FAILURE; _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DetachSharedMemory(): munmap failed: %s, errno: %d", - shm->ipcname, PR_GetOSError())); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DetachSharedMemory(): munmap failed: %s, errno: %d", + shm->ipcname, PR_GetOSError())); } return rc; -} +} extern PRStatus _MD_CloseSharedMemory( PRSharedMemory *shm ) { int urc; - + PR_ASSERT( shm->ident == _PR_SHM_IDENT ); urc = close( shm->id ); if ( -1 == urc ) { _PR_MD_MAP_CLOSE_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_CloseSharedMemory(): close() failed, error: %d", PR_GetOSError())); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_CloseSharedMemory(): close() failed, error: %d", PR_GetOSError())); return(PR_FAILURE); } PR_DELETE( shm->ipcname ); PR_DELETE( shm ); return PR_SUCCESS; -} +} extern PRStatus _MD_DeleteSharedMemory( const char *name ) { @@ -433,9 +430,9 @@ extern PRStatus _MD_DeleteSharedMemory( const char *name ) rc = _PR_MakeNativeIPCName( name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm ); if ( PR_FAILURE == rc ) { - PR_SetError( PR_UNKNOWN_ERROR , errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); + PR_SetError( PR_UNKNOWN_ERROR, errno ); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_OpenSharedMemory(): _PR_MakeNativeIPCName() failed: %s", name )); return rc; } @@ -443,12 +440,12 @@ extern PRStatus _MD_DeleteSharedMemory( const char *name ) if ( -1 == urc ) { rc = PR_FAILURE; _PR_MD_MAP_DEFAULT_ERROR( errno ); - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DeleteSharedMemory(): shm_unlink failed: %s, errno: %d", - ipcname, PR_GetOSError())); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DeleteSharedMemory(): shm_unlink failed: %s, errno: %d", + ipcname, PR_GetOSError())); } else { - PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, - ("_MD_DeleteSharedMemory(): %s, success", ipcname)); + PR_LOG( _pr_shm_lm, PR_LOG_DEBUG, + ("_MD_DeleteSharedMemory(): %s, success", ipcname)); } return rc; @@ -464,7 +461,7 @@ extern PRLogModuleInfo *_pr_shma_lm; #include <unistd.h> -extern PRFileMap* _md_OpenAnonFileMap( +extern PRFileMap* _md_OpenAnonFileMap( const char *dirName, PRSize size, PRFileMapProtect prot @@ -488,100 +485,90 @@ extern PRFileMap* _md_OpenAnonFileMap( ** make maxTries number of attempts at uniqueness in the filename */ for ( incr = 0; incr < maxTries ; incr++ ) { -#if defined(SYMBIAN) -#define NSPR_AFM_FILENAME "%s\\NSPR-AFM-%d-%p.%d" -#else #define NSPR_AFM_FILENAME "%s/.NSPR-AFM-%d-%p.%d" -#endif genName = PR_smprintf( NSPR_AFM_FILENAME, - dirName, (int) pid, tid, incr ); + dirName, (int) pid, tid, incr ); if ( NULL == genName ) { PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): PR_snprintf(): failed, generating filename")); + ("_md_OpenAnonFileMap(): PR_snprintf(): failed, generating filename")); goto Finished; } /* create the file */ osfd = open(genName, (O_CREAT | O_EXCL | O_RDWR), mode); if (-1 == osfd) { - if (EEXIST == errno) { + if (EEXIST == errno) { + PR_smprintf_free(genName); + continue; /* name exists, try again */ + } + _PR_MD_MAP_OPEN_ERROR(errno); + PR_LOG( + _pr_shma_lm, + PR_LOG_DEBUG, + ("_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d", + genName, + PR_GetOSError())); PR_smprintf_free(genName); - continue; /* name exists, try again */ - } - _PR_MD_MAP_OPEN_ERROR(errno); - PR_LOG( - _pr_shma_lm, - PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d", - genName, - PR_GetOSError())); - PR_smprintf_free(genName); - goto Finished; + goto Finished; } break; /* name generation and open successful, break; */ } /* end for() */ if (incr == maxTries) { - PR_ASSERT(-1 == osfd); - PR_ASSERT(EEXIST == errno); - _PR_MD_MAP_OPEN_ERROR(errno); - goto Finished; + PR_ASSERT(-1 == osfd); + PR_ASSERT(EEXIST == errno); + _PR_MD_MAP_OPEN_ERROR(errno); + goto Finished; } urc = unlink( genName ); -#if defined(SYMBIAN) && defined(__WINS__) - /* If it is being used by the system or another process, Symbian OS - * Emulator(WINS) considers this an error. */ - if ( -1 == urc && EACCES != errno ) { -#else if ( -1 == urc ) { -#endif _PR_MD_MAP_UNLINK_ERROR( errno ); PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): failed on unlink(), errno: %d", errno)); + ("_md_OpenAnonFileMap(): failed on unlink(), errno: %d", errno)); PR_smprintf_free( genName ); close( osfd ); - goto Finished; + goto Finished; } PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): unlink(): %s", genName )); + ("_md_OpenAnonFileMap(): unlink(): %s", genName )); PR_smprintf_free( genName ); fd = PR_ImportFile( osfd ); if ( NULL == fd ) { PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): PR_ImportFile(): failed")); - goto Finished; + ("_md_OpenAnonFileMap(): PR_ImportFile(): failed")); + goto Finished; } PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): fd: %p", fd )); + ("_md_OpenAnonFileMap(): fd: %p", fd )); urc = ftruncate( fd->secret->md.osfd, size ); if ( -1 == urc ) { _PR_MD_MAP_DEFAULT_ERROR( errno ); PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): failed on ftruncate(), errno: %d", errno)); + ("_md_OpenAnonFileMap(): failed on ftruncate(), errno: %d", errno)); PR_Close( fd ); - goto Finished; + goto Finished; } PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): ftruncate(): size: %d", size )); + ("_md_OpenAnonFileMap(): ftruncate(): size: %d", size )); LL_UI2L(size64, size); /* PRSize (size_t) is unsigned */ fm = PR_CreateFileMap( fd, size64, prot ); if ( NULL == fm ) { PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("PR_OpenAnonFileMap(): failed")); + ("PR_OpenAnonFileMap(): failed")); PR_Close( fd ); - goto Finished; + goto Finished; } fm->md.isAnonFM = PR_TRUE; /* set fd close */ PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_OpenAnonFileMap(): PR_CreateFileMap(): fm: %p", fm )); + ("_md_OpenAnonFileMap(): PR_CreateFileMap(): fm: %p", fm )); -Finished: +Finished: return(fm); } /* end md_OpenAnonFileMap() */ @@ -598,10 +585,10 @@ extern PRStatus _md_ExportFileMapAsString( { PRIntn written; PRIntn prot = (PRIntn)fm->prot; - + written = PR_snprintf( buf, bufSize, "%ld:%d", - fm->fd->secret->md.osfd, prot ); - + fm->fd->secret->md.osfd, prot ); + return((written == -1)? PR_FAILURE : PR_SUCCESS); } /* end _md_ExportFileMapAsString() */ @@ -623,21 +610,21 @@ extern PRFileMap * _md_ImportFileMapFromString( fd = PR_ImportFile( osfd ); if ( NULL == fd ) { PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_ImportFileMapFromString(): PR_ImportFile() failed")); + ("_md_ImportFileMapFromString(): PR_ImportFile() failed")); goto Finished; } rc = PR_GetOpenFileInfo64( fd, &info ); if ( PR_FAILURE == rc ) { PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_ImportFileMapFromString(): PR_GetOpenFileInfo64() failed")); + ("_md_ImportFileMapFromString(): PR_GetOpenFileInfo64() failed")); goto Finished; } fm = PR_CreateFileMap( fd, info.size, (PRFileMapProtect)prot ); if ( NULL == fm ) { PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, - ("_md_ImportFileMapFromString(): PR_CreateFileMap() failed")); + ("_md_ImportFileMapFromString(): PR_CreateFileMap() failed")); } Finished: |