aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:32 -0500
committerJacek Antonelli2008-08-15 23:45:32 -0500
commit77c4904770841a44ea74a93dc9741b1fafe35a0e (patch)
treeb7bab4dc6368b2aa8e2b7053ee69b61c7aff1e0b /linden/indra/newview/llappviewer.cpp
parentSecond Life viewer sources 1.19.0.3 (diff)
downloadmeta-impy-77c4904770841a44ea74a93dc9741b1fafe35a0e.zip
meta-impy-77c4904770841a44ea74a93dc9741b1fafe35a0e.tar.gz
meta-impy-77c4904770841a44ea74a93dc9741b1fafe35a0e.tar.bz2
meta-impy-77c4904770841a44ea74a93dc9741b1fafe35a0e.tar.xz
Second Life viewer sources 1.19.0.4
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llappviewer.cpp44
1 files changed, 11 insertions, 33 deletions
diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp
index e3d7073..30ac8fa 100644
--- a/linden/indra/newview/llappviewer.cpp
+++ b/linden/indra/newview/llappviewer.cpp
@@ -2610,43 +2610,36 @@ void LLAppViewer::setCrashBehavior(S32 cb)
2610 2610
2611bool LLAppViewer::anotherInstanceRunning() 2611bool LLAppViewer::anotherInstanceRunning()
2612{ 2612{
2613 // We create a marker file when the program starts and remove the file when it finishes. 2613 // We create a marker file when the program starts and remove the file when it finishes.
2614 // If the file is currently locked, that means another process is already running. 2614 // If the file is currently locked, that means another process is already running.
2615 2615
2616 std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, MARKER_FILE_NAME); 2616 std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, MARKER_FILE_NAME);
2617 llinfos << "Checking marker file for lock..." << llendl; 2617 llinfos << "Checking marker file for lock..." << llendl;
2618 2618
2619 // If file doesn't exist, we create it 2619 //Freeze case checks
2620 // If file does exist, try to get writing privileges 2620 apr_file_t* fMarker = ll_apr_file_open(marker_file, LL_APR_RB);
2621 FILE* fMarker = LLFile::fopen(marker_file.c_str(), "rb"); // Flawfinder: ignore
2622 if (fMarker != NULL) 2621 if (fMarker != NULL)
2623 { 2622 {
2624 // File exists, try opening with write permissions 2623 // File exists, try opening with write permissions
2625 fclose(fMarker); 2624 apr_file_close(fMarker);
2626 fMarker = LLFile::fopen(marker_file.c_str(), "wb"); // Flawfinder: ignore 2625 fMarker = ll_apr_file_open(marker_file, LL_APR_WB);
2627 if (fMarker == NULL) 2626 if (fMarker == NULL)
2628 { 2627 {
2628 // Another instance is running. Skip the rest of these operations.
2629 llinfos << "Marker file is locked." << llendl; 2629 llinfos << "Marker file is locked." << llendl;
2630 return TRUE; 2630 return TRUE;
2631 } 2631 }
2632 2632 if (apr_file_lock(fMarker, APR_FLOCK_NONBLOCK | APR_FLOCK_EXCLUSIVE) != APR_SUCCESS) //flock(fileno(fMarker), LOCK_EX | LOCK_NB) == -1)
2633 // *FIX:Mani - rather than have this exception here,
2634 // LLFile::fopen() have consistent behavior across platforms?
2635#if LL_DARWIN || LL_LINUX || LL_SOLARIS
2636 // Try to lock it. On Mac, this is the only way to test if it's actually locked.
2637 if (flock(fileno(fMarker), LOCK_EX | LOCK_NB) == -1)
2638 { 2633 {
2639 // Lock failed - somebody else has it. 2634 apr_file_close(fMarker);
2640 fclose(fMarker);
2641 llinfos << "Marker file is locked." << llendl; 2635 llinfos << "Marker file is locked." << llendl;
2642 return TRUE; 2636 return TRUE;
2643 } 2637 }
2644#endif 2638 // No other instances; we'll lock this file now & delete on quit.
2645 fclose(fMarker); 2639 apr_file_close(fMarker);
2646 } 2640 }
2647 llinfos << "Marker file isn't locked." << llendl; 2641 llinfos << "Marker file isn't locked." << llendl;
2648 return FALSE; 2642 return FALSE;
2649
2650} 2643}
2651 2644
2652void LLAppViewer::initMarkerFile() 2645void LLAppViewer::initMarkerFile()
@@ -2688,25 +2681,10 @@ void LLAppViewer::initMarkerFile()
2688 ll_apr_file_remove(error_marker_file); 2681 ll_apr_file_remove(error_marker_file);
2689 2682
2690 //Freeze case checks 2683 //Freeze case checks
2684 if(anotherInstanceRunning()) return;
2691 fMarker = ll_apr_file_open(mMarkerFileName, LL_APR_RB); 2685 fMarker = ll_apr_file_open(mMarkerFileName, LL_APR_RB);
2692 if (fMarker != NULL) 2686 if (fMarker != NULL)
2693 { 2687 {
2694 // File exists, try opening with write permissions
2695 apr_file_close(fMarker);
2696 fMarker = ll_apr_file_open(mMarkerFileName, LL_APR_WB);
2697 if (fMarker == NULL)
2698 {
2699 // Another instance is running. Skip the rest of these operations.
2700 llinfos << "Marker file is locked." << llendl;
2701 return;
2702 }
2703 if (apr_file_lock(fMarker, APR_FLOCK_NONBLOCK | APR_FLOCK_EXCLUSIVE) != APR_SUCCESS) //flock(fileno(fMarker), LOCK_EX | LOCK_NB) == -1)
2704 {
2705 apr_file_close(fMarker);
2706 llinfos << "Marker file is locked." << llendl;
2707 return;
2708 }
2709 // No other instances; we'll lock this file now & delete on quit.
2710 apr_file_close(fMarker); 2688 apr_file_close(fMarker);
2711 gLastExecEvent = LAST_EXEC_FROZE; 2689 gLastExecEvent = LAST_EXEC_FROZE;
2712 llinfos << "Exec marker found: program froze on previous execution" << llendl; 2690 llinfos << "Exec marker found: program froze on previous execution" << llendl;