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 / proto-error.sm < prev    next >
Text File  |  2010-12-21  |  2KB  |  113 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 "server-config.h"
  15.  
  16. %%
  17.  
  18. machine pvfs2_proto_error_sm
  19. {
  20.     state init
  21.     {
  22.         run proto_error_init;
  23.         default => cleanup;
  24.     }
  25.  
  26.     state cleanup
  27.     {
  28.         run proto_error_cleanup;
  29.         default => terminate;
  30.     }
  31. }
  32.  
  33. %%
  34.  
  35. /* proto_error_init()
  36.  *
  37.  * encode and send a response indicating a protocol error
  38.  */
  39. static PINT_sm_action proto_error_init(
  40.         struct PINT_smcb *smcb, job_status_s *js_p)
  41. {
  42.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  43.     int ret;
  44.     job_id_t tmp_id;
  45.     struct server_configuration_s *user_opts = get_server_config_struct();
  46.  
  47.     s_op->resp.op = PVFS_SERV_PROTO_ERROR;
  48.     s_op->resp.status = -PVFS_EPROTO;
  49.  
  50.     /* encode message */
  51.     ret = PINT_encode(&s_op->resp,
  52.               PINT_ENCODE_RESP,
  53.               &(s_op->encoded),
  54.               s_op->addr,
  55.               PVFS2_ENCODING_DEFAULT);
  56.     if (ret < 0)
  57.     {
  58.     gossip_lerr("Error: PINT_encode() failure.\n");
  59.     /* TODO: probably should dump contents of response to give 
  60.      * some clues as to what went wrong
  61.      */
  62.     js_p->error_code = ret;
  63.     return SM_ACTION_COMPLETE;
  64.     }
  65.  
  66.     /* send the response */
  67.     ret = job_bmi_send_list(s_op->addr,
  68.                 s_op->encoded.buffer_list,
  69.                 s_op->encoded.size_list,
  70.                 s_op->encoded.list_count,
  71.                 s_op->encoded.total_size,
  72.                 s_op->tag,
  73.                 s_op->encoded.buffer_type,
  74.                 0,
  75.                 smcb,
  76.                 0,
  77.                 js_p,
  78.                 &tmp_id,
  79.                 server_job_context,
  80.                 user_opts->server_job_bmi_timeout, NULL);
  81.  
  82.     return ret;
  83. }
  84.  
  85. /* proto_error_cleanup()
  86.  *
  87.  * cleans up any resources consumed by this state machine and ends
  88.  * execution of the machine
  89.  */
  90. static PINT_sm_action proto_error_cleanup(
  91.         struct PINT_smcb *smcb, job_status_s *js_p)
  92. {
  93.     return(server_state_machine_complete(smcb));
  94. }
  95.  
  96. struct PINT_server_req_params pvfs2_proto_error_params =
  97. {
  98.     .string_name = "proto_error",
  99.     .state_machine = &pvfs2_proto_error_sm
  100. };
  101.  
  102.  
  103. /*
  104.  * Local variables:
  105.  *  mode: c
  106.  *  c-indent-level: 4
  107.  *  c-basic-offset: 4
  108.  * End:
  109.  *
  110.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  111.  */
  112.  
  113.