home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / server / unexpected.sm < prev    next >
Text File  |  2009-01-29  |  3KB  |  125 lines

  1. /* 
  2.  * (C) 2001 Clemson University and The University of Chicago 
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <unistd.h>
  11. #include <fcntl.h>
  12.  
  13. #include "pvfs2-server.h"
  14. #include "quicklist.h"
  15.  
  16. %%
  17.  
  18. machine pvfs2_unexpected_sm
  19. {
  20.     state post_unexpected
  21.     {
  22.         run unexpected_post;
  23.         default => map_request;
  24.     }
  25.  
  26.     state map_request
  27.     {
  28.         run unexpected_map;
  29.         default => terminate;
  30.     }
  31. }
  32.  
  33. %%
  34.  
  35. /* unexpected_post()
  36.  *
  37.  * Post an unexpected receive
  38.  */
  39. static PINT_sm_action unexpected_post(
  40.         struct PINT_smcb *smcb, job_status_s *js_p)
  41. {
  42.     int ret = -PVFS_EINVAL;
  43.     struct PINT_server_op *s_op =
  44.             (struct PINT_server_op *)PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  45.  
  46.     /*
  47.        TODO: Consider the optimization of enabling immediate
  48.        completion in this part of the code (see the mailing list
  49.        thread from Feb. 2003 on pvfs2-internal).
  50.                                                                                 
  51.        note: unexp_bmi_buff is really a struct that describes an
  52.        unexpected message (it is an output parameter).
  53.      */
  54.     ret = job_bmi_unexp(&s_op->unexp_bmi_buff, smcb, 0,
  55.                         js_p, &s_op->unexp_id, JOB_NO_IMMED_COMPLETE,
  56.                         server_job_context);
  57.     if(ret == SM_ACTION_COMPLETE)
  58.     {
  59.         PVFS_perror_gossip("Error: job_bmi_unexp failure", ret);
  60.         return SM_ACTION_TERMINATE;
  61.     }
  62.     return SM_ACTION_DEFERRED;
  63. }
  64.  
  65. /* unexpected_map()
  66.  *
  67.  * Change the state machine OP to that of the received request
  68.  * This instance will continue execution in another state machine
  69.  * Set up another unexpected receive
  70.  */
  71. static PINT_sm_action unexpected_map(
  72.         struct PINT_smcb *smcb, job_status_s *js_p)
  73. {
  74.     int ret = 0;
  75.     PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  76.  
  77.     /* Remove s_op from posted_sop_list */
  78.     qlist_del(&s_op->next);
  79.     /* If op was cancelled, kill the SM */
  80.     if (s_op->op_cancelled)
  81.     {
  82.         return SM_ACTION_TERMINATE;
  83.     }
  84.     /* Else move it to the inprogress_sop_list */
  85.     qlist_add_tail(&s_op->next, &inprogress_sop_list);
  86.  
  87.     /* start replacement unexpected recv */
  88.     ret = server_post_unexpected_recv(js_p);
  89.     if (ret < 0)
  90.     {
  91.         /* TODO: do something here, the return value was
  92.          * not being checked for failure before.  I just
  93.          * put something here to make it exit for the
  94.          * moment.  -Phil
  95.          */
  96.         gossip_lerr("Error: post unexpected failure when restarting.\n");
  97.     }
  98.  
  99.     /* restart as new request state machine */
  100.     memset(js_p, 0, sizeof(job_status_s));
  101.     ret = server_state_machine_start(smcb, js_p);
  102.     if (ret < 0)
  103.     {
  104.         PVFS_perror_gossip("Error: server_state_machine_start", ret);
  105.         /* TODO: tell BMI to drop this address? */
  106.         /* set return code to let this SM end
  107.          */
  108.         ret = SM_ACTION_TERMINATE;
  109.     }
  110.  
  111.     return ret;
  112. }
  113.  
  114.  
  115. /*
  116.  * Local variables:
  117.  *  mode: c
  118.  *  c-indent-level: 4
  119.  *  c-basic-offset: 4
  120.  * End:
  121.  *
  122.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  123.  */
  124.  
  125.