- fprintf(stdout, "tids_read_request():Request Received, %d bytes.\n", buflen);
-
- /* Parse request */
- if (NULL == ((*mreq) = tr_msg_decode(buf, buflen))) {
- printf("tids_read_request():Error decoding request.\n");
- free (buf);
- return -1;
+ tr_debug("tids_handle_request: adding self to req path.");
+ tid_req_add_path(req, tids->hostname, tids->tids_port);
+
+ /* Call the caller's request handler */
+ /* TBD -- Handle different error returns/msgs */
+ if (0 > (rc = (*tids->req_handler)(tids, req, resp, tids->cookie))) {
+ /* set-up an error response */
+ tr_debug("tids_handle_request: req_handler returned error.");
+ tid_resp_set_result(resp, TID_ERROR);
+ if (!tid_resp_get_err_msg(resp)) /* Use msg set by handler, if any */
+ tid_resp_set_err_msg(resp, tr_new_name("Internal processing error"));
+ } else {
+ /* set-up a success response */
+ tr_debug("tids_handle_request: req_handler returned success.");
+ tid_resp_set_result(resp, TID_SUCCESS);
+ resp->err_msg = NULL; /* No error msg on successful return */