| 47 | } |
| 48 | |
| 49 | action_t module::execute() |
| 50 | { |
| 51 | logger::log(1,"Module has started"); |
| 52 | action_t action=action_continue; |
| 53 | std::string line; |
| 54 | while(action==action_continue) |
| 55 | { |
| 56 | try |
| 57 | { |
| 58 | line=getline(); |
| 59 | cmd_map::iterator it=subcommands.find(line); |
| 60 | if(it==subcommands.end()) |
| 61 | { |
| 62 | logger::log(4,"Unknown command: ",line); |
| 63 | reply()("300 ERROR UNKNOWN COMMAND"); |
| 64 | } |
| 65 | else |
| 66 | { |
| 67 | logger::log(4,"Received command ",line); |
| 68 | action=it->second->run(); |
| 69 | } |
| 70 | } |
| 71 | catch(const std::exception& e) |
| 72 | { |
| 73 | logger::log(2,"aborting because of an unexpected error: ",e.what()); |
| 74 | action=action_abort; |
| 75 | } |
| 76 | } |
| 77 | try |
| 78 | { |
| 79 | close(); |
| 80 | } |
| 81 | catch(const std::exception& e) |
| 82 | { |
| 83 | logger::log(2,"Error while closing the module: ",e.what()); |
| 84 | } |
| 85 | logger::log(1,"Exiting"); |
| 86 | return action; |
| 87 | } |
| 88 | |
| 89 | void module::close() |
| 90 | { |