@@ -18,13 +18,10 @@ pub mod error;
1818
1919use error:: IptablesError ;
2020use lazy_static:: lazy_static;
21- use nix:: fcntl:: { FlockArg , flock} ;
2221use regex:: { Match , Regex } ;
2322use std:: convert:: From ;
2423use std:: error:: Error ;
2524use std:: ffi:: OsStr ;
26- use std:: fs:: File ;
27- use std:: os:: unix:: io:: AsRawFd ;
2825use std:: process:: { Command , Output } ;
2926use std:: vec:: Vec ;
3027
@@ -407,38 +404,15 @@ impl IPTables {
407404 }
408405
409406 fn run < S : AsRef < OsStr > > ( & self , args : & [ S ] ) -> Result < Output , Box < dyn Error > > {
410- let mut file_lock = None ;
411-
412407 let mut output_cmd = Command :: new ( self . cmd ) ;
413408 let output;
414409
415410 if self . has_wait {
416411 output = output_cmd. args ( args) . arg ( "--wait" ) . output ( ) ?;
417412 } else {
418- file_lock = Some ( File :: create ( "/var/run/xtables_old.lock" ) ?) ;
419-
420- let mut need_retry = true ;
421- while need_retry {
422- match flock (
423- file_lock. as_ref ( ) . unwrap ( ) . as_raw_fd ( ) ,
424- FlockArg :: LockExclusiveNonblock ,
425- ) {
426- Ok ( _) => need_retry = false ,
427- Err ( e) if e == nix:: errno:: Errno :: EAGAIN => {
428- // FIXME: may cause infinite loop
429- need_retry = true ;
430- }
431- Err ( e) => {
432- return Err ( Box :: new ( e) ) ;
433- }
434- }
435- }
436413 output = output_cmd. args ( args) . output ( ) ?;
437414 }
438415
439- if let Some ( f) = file_lock {
440- drop ( f)
441- }
442416 Ok ( output)
443417 }
444418}
0 commit comments