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 / event-mon.sm < prev    next >
Text File  |  2008-11-19  |  2KB  |  105 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. #include <sys/time.h>
  13.  
  14. #include "pvfs2-server.h"
  15. #include "pint-event.h"
  16.  
  17. %%
  18.  
  19. machine pvfs2_event_mon_sm
  20. {
  21.     state prelude
  22.     {
  23.         jump pvfs2_prelude_sm;
  24.         default => do_work;
  25.     }
  26.  
  27.     state do_work
  28.     {
  29.         run event_mon_do_work;
  30.         default => final_response;
  31.     }
  32.  
  33.     state final_response
  34.     {
  35.         jump pvfs2_final_response_sm;
  36.         default => cleanup;
  37.     }
  38.  
  39.     state cleanup
  40.     {
  41.         run event_mon_cleanup;
  42.         default => terminate;
  43.     }
  44. }
  45.  
  46. %%
  47.  
  48. /* event_mon_cleanup()
  49.  *
  50.  * cleans up any resources consumed by this state machine and ends
  51.  * execution of the machine
  52.  */
  53. static PINT_sm_action event_mon_cleanup(
  54.         struct PINT_smcb *smcb, job_status_s *js_p)
  55. {
  56.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  57.     if(s_op->resp.u.mgmt_event_mon.event_array)
  58.     free(s_op->resp.u.mgmt_event_mon.event_array);
  59.  
  60.     return(server_state_machine_complete(smcb));
  61. }
  62.  
  63. /* event_mon_do_work()
  64.  *
  65.  * gathers statistics and builds response
  66.  */
  67. static PINT_sm_action event_mon_do_work(
  68.         struct PINT_smcb *smcb, job_status_s *js_p)
  69. {
  70.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  71.     /* allocate memory to hold events */
  72.     s_op->resp.u.mgmt_event_mon.event_array
  73.     = (struct PVFS_mgmt_event*)malloc(s_op->req->u.mgmt_event_mon.event_count
  74.     *sizeof(struct PVFS_mgmt_event));
  75.     if(!s_op->resp.u.mgmt_event_mon.event_array)
  76.     {
  77.     js_p->error_code = -PVFS_ENOMEM;
  78.     return SM_ACTION_COMPLETE;
  79.     }
  80.  
  81.     s_op->resp.u.mgmt_event_mon.event_count = 
  82.     s_op->req->u.mgmt_event_mon.event_count;
  83.  
  84.     js_p->error_code = 0;
  85.     return SM_ACTION_COMPLETE;
  86. }
  87.  
  88. struct PINT_server_req_params pvfs2_event_mon_params =
  89. {
  90.     .string_name = "mgmt_event_mon",
  91.     .perm = PINT_SERVER_CHECK_NONE,
  92.     .state_machine = &pvfs2_event_mon_sm
  93. };
  94.  
  95. /*
  96.  * Local variables:
  97.  *  mode: c
  98.  *  c-indent-level: 4
  99.  *  c-basic-offset: 4
  100.  * End:
  101.  *
  102.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  103.  */
  104.  
  105.