- Timestamp:
- Nov 22, 2007, 4:43:10 PM (17 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r428 r429 1 2007-11-22 <rybkin@lal.in2p3.fr> 335 2 3 * source/cmt_generators.h: idem 4 * source/cmt_generators.cxx: idem 5 * source/cmt_lock.cxx: idem 6 * mgr/fragments/constituent_lock: idem 7 * mgr/fragments/nmake/constituent_lock: idem 8 * mgr/requirements: Implement a locking mechanism to allow simultaneous/parallel 9 builds for multiple binary tags. Used suggestions from Pere, Stefan, and Andrea 10 * mgr/lockfile.bat: Basic semaphore-file creator for Windows 11 * mgr/lockfile.sh: Basic semaphore-file creator for Unix 12 1 13 2007-10-31 <rybkin@lal.in2p3.fr> 334 2 14 -
CMT/HEAD/mgr/requirements
r348 r429 445 445 macro library_suffix "" 446 446 447 macro lock_command "chmod -R a-w ../*" \ 448 VisualC "attrib /S /D +R ..\*" 449 450 macro unlock_command "chmod -R g+w ../*" \ 451 VisualC "attrib /S /D -R ..\*" 447 macro lock_command "" \ 448 Linux "lockfile " \ 449 Darwin "lockfile " \ 450 VisualC "%CMTROOT%\mgr\lockfile.bat " 451 452 macro unlock_command "rm -rf " \ 453 VisualC "rmdir " 454 455 macro lock_name "cmt" 456 macro lock_suffix ".lock" 457 macro lock_file "${lock_name}${lock_suffix}" 452 458 453 459 macro preprocessor_command "" \ … … 554 560 make_fragment group 555 561 make_fragment constituent 562 make_fragment constituent_lock 556 563 make_fragment constituents_trailer 557 564 -
CMT/HEAD/source/cmt_generators.cxx
r428 r429 2404 2404 group_fragment.set ("group"); 2405 2405 constituent_fragment.set ("constituent"); 2406 constituent_lock_fragment.set ("constituent_lock"); 2406 2407 check_application_header_fragment.set ("check_application_header"); 2407 2408 } … … 2414 2415 group_fragment.reset (); 2415 2416 constituent_fragment.reset (); 2417 constituent_lock_fragment.reset (); 2416 2418 check_application_header_fragment.reset (); 2417 2419 } … … 2452 2454 2453 2455 cmt_string save_file_name = file_name; 2454 save_file_name += " sav";2456 save_file_name += "cmtsave"; 2455 2457 2456 2458 if (CmtSystem::test_file (file_name)) … … 2487 2489 } 2488 2490 2491 bool lock = false; 2492 Symbol* lock_command_macro = Symbol::find ("lock_command"); 2493 if (lock_command_macro != 0) 2494 { 2495 cmt_string lock_command = lock_command_macro->resolve_macro_value (); 2496 if (lock_command != "") 2497 { 2498 Symbol* unlock_command_macro = Symbol::find ("unlock_command"); 2499 if (unlock_command_macro != 0) 2500 { 2501 cmt_string unlock_command = unlock_command_macro->resolve_macro_value (); 2502 if (unlock_command != "") 2503 { 2504 lock = true; 2505 } 2506 } 2507 } 2508 } 2489 2509 for (number = 0; number < constituents.size (); number++) 2490 2510 { … … 2505 2525 } 2506 2526 2507 constituent_fragment.copy (m_output_file, constituent.variables, 5, 2508 &m_PACKAGE, 2509 &m_CONSTITUENT, 2510 &m_CONSTITUENTSUFFIX, 2511 &m_LINE, 2512 &m_HASTARGETTAG); 2527 if (constituent.type == Document && lock == true) 2528 { 2529 constituent_lock_fragment.copy (m_output_file, constituent.variables, 2530 5, 2531 &m_PACKAGE, 2532 &m_CONSTITUENT, 2533 &m_CONSTITUENTSUFFIX, 2534 &m_LINE, 2535 &m_HASTARGETTAG); 2536 } 2537 else 2538 { 2539 constituent_fragment.copy (m_output_file, constituent.variables, 2540 5, 2541 &m_PACKAGE, 2542 &m_CONSTITUENT, 2543 &m_CONSTITUENTSUFFIX, 2544 &m_LINE, 2545 &m_HASTARGETTAG); 2546 } 2513 2547 2514 2548 if (constituent.need_check) -
CMT/HEAD/source/cmt_generators.h
r428 r429 208 208 FragmentHandle group_fragment; 209 209 FragmentHandle constituent_fragment; 210 FragmentHandle constituent_lock_fragment; 210 211 FragmentHandle check_application_header_fragment; 211 212 }; -
CMT/HEAD/source/cmt_lock.cxx
r400 r429 14 14 CmtLock::status CmtLock::lock () 15 15 { 16 status s = check ();16 // status s = check (); 17 17 18 switch (s) 18 // switch (s) 19 // { 20 // case locked_by_user: 21 // cerr << "Package already locked by you" << endl; 22 // return (s); 23 // case locked_by_another_user: 24 // CmtError::set (CmtError::cannot_lock, "lock> Package already locked by another user"); 25 // return (s); 26 // case not_locked: 27 // break; 28 // } 29 30 // cmt_string text = "locked by "; 31 // text += CmtSystem::user (); 32 // text += " date "; 33 // text += CmtSystem::now (); 34 35 // if (!text.write ("lock.cmt")) 36 // { 37 // CmtError::set (CmtError::cannot_write_lock, "lock>"); 38 // return (still_unlocked); 39 // } 40 41 // cmt_string command = lock_command->build_macro_value (); 42 43 cmt_string lock_command; 44 Symbol* lock_command_macro = Symbol::find ("lock_command"); 45 if (lock_command_macro != 0) 19 46 { 20 case locked_by_user: 21 cerr << "Package already locked by you" << endl; 22 return (s); 23 case locked_by_another_user: 24 CmtError::set (CmtError::cannot_lock, "lock> Package already locked by another user"); 25 return (s); 26 case not_locked: 27 break; 47 lock_command = lock_command_macro->resolve_macro_value (); 28 48 } 29 30 cmt_string text = "locked by "; 31 text += CmtSystem::user (); 32 text += " date "; 33 text += CmtSystem::now (); 34 35 if (!text.write ("lock.cmt")) 49 if (lock_command == "") 36 50 { 37 51 CmtError::set (CmtError::cannot_write_lock, "lock>"); … … 39 53 } 40 54 41 Symbol* lock_command = Symbol::find ("lock_command"); 42 if (lock_command != 0) 55 cmt_string lock_file; 56 Symbol* lock_file_macro = Symbol::find ("lock_file"); 57 if (lock_file_macro != 0) 43 58 { 44 cmt_string command = lock_command->build_macro_value (); 59 lock_file = lock_file_macro->resolve_macro_value (); 60 } 61 if (lock_file == "") 62 { 63 CmtError::set (CmtError::cannot_write_lock, "lock>"); 64 return (still_unlocked); 65 } 45 66 46 if (command != "") 47 { 48 if (CmtSystem::execute (command) != 0) 49 { 50 CmtError::set (CmtError::cannot_run_lock_command, "lock>"); 51 return (still_unlocked); 52 } 53 } 67 cmt_string command = lock_command + " " + lock_file; 68 69 if (CmtSystem::execute (command) != 0) 70 { 71 CmtError::set (CmtError::cannot_run_lock_command, "lock>"); 72 return (still_unlocked); 54 73 } 55 74 … … 72 91 return (s); 73 92 case not_locked: 74 cerr << " The package wasnot locked" << endl;93 cerr << "Package not locked" << endl; 75 94 return (s); 76 95 } 77 96 78 Symbol* unlock_command = Symbol::find ("unlock_command"); 79 if (unlock_command != 0) 97 // Symbol* unlock_command = Symbol::find ("unlock_command"); 98 // if (unlock_command != 0) 99 // { 100 // cmt_string command = unlock_command->build_macro_value (); 101 102 // if (command != "") 103 // { 104 // if (CmtSystem::execute (command) != 0) 105 // { 106 // CmtError::set (CmtError::cannot_run_unlock_command, "unlock>"); 107 // return (still_locked); 108 // } 109 // } 110 // } 111 112 // if (!CmtSystem::remove_file ("lock.cmt")) 113 // { 114 // CmtError::set (CmtError::cannot_remove_lock, "unlock>"); 115 // return (still_locked); 116 // } 117 118 cmt_string unlock_command; 119 Symbol* unlock_command_macro = Symbol::find ("unlock_command"); 120 if (unlock_command_macro != 0) 80 121 { 81 cmt_string command = unlock_command->build_macro_value (); 82 83 if (command != "") 84 { 85 if (CmtSystem::execute (command) != 0) 86 { 87 CmtError::set (CmtError::cannot_run_unlock_command, "unlock>"); 88 return (still_locked); 89 } 90 } 122 unlock_command = unlock_command_macro->resolve_macro_value (); 123 } 124 if (unlock_command == "") 125 { 126 CmtError::set (CmtError::cannot_remove_lock, "unlock>"); 127 return (still_locked); 91 128 } 92 129 93 if (!CmtSystem::remove_file ("lock.cmt")) 130 cmt_string lock_file; 131 Symbol* lock_file_macro = Symbol::find ("lock_file"); 132 if (lock_file_macro != 0) 133 { 134 lock_file = lock_file_macro->resolve_macro_value (); 135 } 136 if (lock_file == "") 94 137 { 95 138 CmtError::set (CmtError::cannot_remove_lock, "unlock>"); 139 return (still_locked); 140 } 141 142 cmt_string command = unlock_command + " " + lock_file; 143 144 if (CmtSystem::execute (command) != 0) 145 { 146 CmtError::set (CmtError::cannot_run_unlock_command, "unlock>"); 96 147 return (still_locked); 97 148 } … … 105 156 CmtLock::status CmtLock::check () 106 157 { 107 cmt_string me = CmtSystem::user ();108 cmt_string text;158 // cmt_string me = CmtSystem::user (); 159 // cmt_string text; 109 160 110 if (text.read ("lock.cmt")) 161 // if (text.read ("lock.cmt")) 162 // { 163 // CmtSystem::cmt_string_vector words; 164 165 // CmtSystem::split (text, " ", words); 166 167 // if (words.size () >= 3) 168 // { 169 // if (words[2] == me) 170 // { 171 // return (locked_by_user); 172 // } 173 // else 174 // { 175 // return (locked_by_another_user); 176 // } 177 // } 178 // } 179 cmt_string lock_file; 180 Symbol* lock_file_macro = Symbol::find ("lock_file"); 181 if (lock_file_macro != 0) 111 182 { 112 CmtSystem::cmt_string_vector words; 183 lock_file = lock_file_macro->resolve_macro_value (); 184 } 113 185 114 CmtSystem::split (text, " ", words); 115 116 if (words.size () >= 3) 117 { 118 if (words[2] == me) 119 { 120 return (locked_by_user); 121 } 122 else 123 { 124 return (locked_by_another_user); 125 } 126 } 186 if (CmtSystem::test_file (lock_file) || CmtSystem::test_directory (lock_file)) 187 { 188 return (locked_by_user); 127 189 } 128 190
Note: See TracChangeset
for help on using the changeset viewer.