FACT++  1.0
void* threadIssue ( void *  threadParam)

Definition at line 2243 of file feeserver.c.

References createLogMessage().

Referenced by command_handler().

2243  {
2244  IssueStruct* issueParam = (IssueStruct*) threadParam;
2245  int status;
2246 
2247  status = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
2248  if (status != 0) {
2249 # ifdef __DEBUG
2250  printf("Set cancel state error: %d\n", status);
2251  fflush(stdout);
2252 # endif
2253  createLogMessage(MSG_WARNING,
2254  "Unable to configure issue thread properly. Execution might eventually be affected.", 0);
2255  }
2256 
2257  status = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
2258  if (status != 0) {
2259 # ifdef __DEBUG
2260  printf("Set cancel type error error: %d\n", status);
2261  fflush(stdout);
2262 # endif
2263  createLogMessage(MSG_WARNING,
2264  "Unable to configure issue thread properly. Execution might eventually be affected.", 0);
2265  }
2266 
2267  // executing command inside CE
2268  issueParam->nRet = issue(issueParam->command, &(issueParam->result), &(issueParam->size));
2269 
2270  //set cancel type to deferred
2271  status = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, 0);
2272  if (status != 0) {
2273 # ifdef __DEBUG
2274  printf("Set cancel type error: %d\n", status);
2275  fflush(stdout);
2276 # endif
2277  createLogMessage(MSG_WARNING,
2278  "Unable to configure issue thread properly. Execution might eventually be affected.", 0);
2279  }
2280 
2281  //lock the mutex before broadcast
2282  status = pthread_mutex_lock(&wait_mut);
2283  if (status != 0) {
2284 # ifdef __DEBUG
2285  printf("Lock cond mutex error: %d\n", status);
2286  fflush(stdout);
2287 # endif
2288  createLogMessage(MSG_WARNING,
2289  "Unable to lock condition mutex for watchdog in issue thread. Execution might eventually be affected.",
2290  0);
2291  }
2292 
2293  //signal that issue has returned from ControlEngine
2294  // maybe try the call pthread_cond_signal instead for performance
2295  pthread_cond_broadcast(&cond);
2296 
2297  // unlock mutex
2298  status = pthread_mutex_unlock(&wait_mut);
2299  if (status != 0) {
2300 # ifdef __DEBUG
2301  printf("Unlock cond mutex error: %d\n", status);
2302  fflush(stdout);
2303 # endif
2304  createLogMessage(MSG_WARNING,
2305  "Unable to unlock condition mutex for watchdog in issue thread. Execution might eventually be affected.",
2306  0);
2307  }
2308 
2309 // not needed, return 0 is better solution
2310 // pthread_exit(0);
2311  return 0;
2312 }
void createLogMessage(unsigned int type, char *description, char *origin)
Definition: feeserver.c:1530
static pthread_mutex_t wait_mut
Definition: feeserver.c:254
static pthread_cond_t cond
Definition: feeserver.c:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function: