Skip to content

Commit 899df24

Browse files
committed
Launcher: check added for command is empty/valid
1 parent 87a220f commit 899df24

1 file changed

Lines changed: 44 additions & 39 deletions

File tree

Launcher.cpp

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -33,67 +33,72 @@ SERVICE_REGISTRATION(Launcher, 1, 0);
3333

3434
config.FromString(_service->ConfigLine());
3535

36-
_closeTime = (config.CloseTime.Value());
36+
if ((config.Command.IsSet() == true) && (config.Command.Value().empty() == false)) {
37+
_closeTime = (config.CloseTime.Value());
3738

38-
if (config.ScheduleTime.IsSet() == true) {
39+
if (config.ScheduleTime.IsSet() == true) {
3940

40-
timeMode = config.ScheduleTime.Mode.Value();
41+
timeMode = config.ScheduleTime.Mode.Value();
4142

42-
time = Time(config.ScheduleTime.Time.Value());
43-
if (time.IsValid() != true) {
44-
SYSLOG(Trace::Fatal, (_T("Time format is wrong")));
45-
}
43+
time = Time(config.ScheduleTime.Time.Value());
44+
if (time.IsValid() != true) {
45+
SYSLOG(Trace::Fatal, (_T("Time format is wrong")));
46+
}
4647

47-
interval = Time(config.ScheduleTime.Interval.Value());
48-
if (interval.IsValid() != true) {
49-
SYSLOG(Trace::Fatal, (_T("Interval format is wrong")));
48+
interval = Time(config.ScheduleTime.Interval.Value());
49+
if (interval.IsValid() != true) {
50+
SYSLOG(Trace::Fatal, (_T("Interval format is wrong")));
51+
}
5052
}
51-
}
5253

53-
_memory = Core::Service<MemoryObserverImpl>::Create<Exchange::IMemory>(0);
54-
ASSERT(_memory != nullptr);
55-
56-
_activity = Core::ProxyType<Job>::Create(&config, interval, _memory);
57-
if (_activity.IsValid() == true) {
58-
if (_activity->IsOperational() == false) {
59-
// Well if we where able to parse the parameters (if needed) we are ready to start it..
60-
_observer.Register(&_notification);
61-
Core::Time scheduledTime;
62-
if (time.IsValid() == true) {
63-
if (timeMode == RELATIVE) { //Schedule Job at relative timing
64-
scheduledTime = Core::Time::Now();
54+
_memory = Core::Service<MemoryObserverImpl>::Create<Exchange::IMemory>(0);
55+
ASSERT(_memory != nullptr);
6556

57+
_activity = Core::ProxyType<Job>::Create(&config, interval, _memory);
58+
if (_activity.IsValid() == true) {
59+
if (_activity->IsOperational() == false) {
60+
// Well if we where able to parse the parameters (if needed) we are ready to start it..
61+
_observer.Register(&_notification);
62+
Core::Time scheduledTime;
63+
if (time.IsValid() == true) {
64+
if (timeMode == RELATIVE) { //Schedule Job at relative timing
65+
scheduledTime = Core::Time::Now();
6666

67-
uint64_t timeValueToTrigger = (((time.HasHours() ? time.Hours(): 0) * MinutesPerHour +
68-
(time.HasMinutes() ? time.Minutes(): 0)) * SecondsPerMinute + time.Seconds()) * MilliSecondsPerSecond;
69-
scheduledTime.Add(timeValueToTrigger);
67+
uint64_t timeValueToTrigger = (((time.HasHours() ? time.Hours(): 0) * MinutesPerHour +
68+
(time.HasMinutes() ? time.Minutes(): 0)) * SecondsPerMinute + time.Seconds()) * MilliSecondsPerSecond;
69+
scheduledTime.Add(timeValueToTrigger);
7070

71-
}
72-
else {
73-
//Schedule Job at absolute timing
74-
if (timeMode == ABSOLUTE_WITH_INTERVAL) {
75-
scheduledTime = FindAbsoluteTimeForSchedule(time, interval);
7671
}
7772
else {
78-
scheduledTime = FindAbsoluteTimeForSchedule(time, Time());
73+
//Schedule Job at absolute timing
74+
if (timeMode == ABSOLUTE_WITH_INTERVAL) {
75+
scheduledTime = FindAbsoluteTimeForSchedule(time, interval);
76+
}
77+
else {
78+
scheduledTime = FindAbsoluteTimeForSchedule(time, Time());
79+
}
7980
}
81+
PluginHost::WorkerPool::Instance().Schedule(scheduledTime, _activity);
82+
}
83+
else {
84+
PluginHost::WorkerPool::Instance().Submit(_activity);
8085
}
81-
PluginHost::WorkerPool::Instance().Schedule(scheduledTime, _activity);
86+
8287
}
8388
else {
84-
PluginHost::WorkerPool::Instance().Submit(_activity);
89+
_activity.Release();
90+
message = _T("Could not parse the configuration for the job.");
8591
}
86-
8792
}
8893
else {
89-
_activity.Release();
90-
message = _T("Could not parse the configuration for the job.");
94+
message = _T("Could not create the job.");
9195
}
9296
}
9397
else {
94-
message = _T("Could not create the job.");
98+
message = _T("Command is not set");
99+
SYSLOG(Trace::Fatal, (message.c_str()));
100+
TRACE_L1(message.c_str());
95101
}
96-
97102
if (_activity.IsValid() == false) {
98103
if (_memory != nullptr) {
99104
_memory->Release();

0 commit comments

Comments
 (0)