Changeset 436 for EcnlProtoTool/trunk/ntshell/webserver/httpd.c
- Timestamp:
- Jul 6, 2020, 9:22:43 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/ntshell/webserver/httpd.c
r331 r436 1 1 /* 2 * TOPPERS ECHONET Lite Communication Middleware2 * TOPPERS PROJECT Home Network Working Group Software 3 3 * 4 * Copyright (C) 2017 Cores Co., Ltd. Japan4 * Copyright (C) 2017-2019 Cores Co., Ltd. Japan 5 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 62 62 SYSTIM httpd_time; 63 63 struct httpd_state *uploding; 64 extern char command[256]; 65 66 extern int execute_command(int wait); 64 static char command[256]; 67 65 68 66 /* TCP 送受信ウィンドバッファ */ … … 367 365 368 366 if (s->message.body_is_final) { 369 syslog(LOG_ERROR, "\n\n *** Error http_body_is_final() should return 1"367 ntstdio_printf(&ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n" 370 368 "on last on_body callback call " 371 369 "but it doesn't! ***\n\n"); … … 405 403 struct httpd_state *s = get_context(p); 406 404 if (s->message.should_keep_alive != http_should_keep_alive(p)) { 407 syslog(LOG_ERROR, "\n\n *** Error http_should_keep_alive() should have same"405 ntstdio_printf(&ntstdio, "\n\n *** Error http_should_keep_alive() should have same \n" 408 406 "value in both on_message_complete and on_headers_complete " 409 407 "but it doesn't! ***\n\n"); … … 414 412 http_body_is_final(p) && 415 413 !s->message.body_is_final) { 416 syslog(LOG_ERROR, "\n\n *** Error http_body_is_final() should return 1"414 ntstdio_printf(&ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n" 417 415 "on last on_body callback call " 418 416 "but it doesn't! ***\n\n"); … … 486 484 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 487 485 if (slen < 0) { 488 syslog(LOG_ERROR, "send_file#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);486 ntstdio_printf(&ntstdio, "send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 489 487 s->state = STATE_CLOSING; 490 488 break; … … 499 497 len = httpd_fs_read(&s->file, buf, len); 500 498 if (len <= 0) { 501 syslog(LOG_ERROR, "send_file#httpd_fs_read(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, len);499 ntstdio_printf(&ntstdio, "send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len); 502 500 break; 503 501 } … … 507 505 508 506 if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) { 509 syslog(LOG_ERROR, "send_file#tcp_snd_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);507 ntstdio_printf(&ntstdio, "send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 510 508 s->state = STATE_CLOSING; 511 509 break; … … 529 527 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 530 528 if (slen < 0) { 531 syslog(LOG_ERROR, "send_data#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);529 ntstdio_printf(&ntstdio, "send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 532 530 s->state = STATE_CLOSING; 533 531 break; … … 546 544 547 545 if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) { 548 syslog(LOG_ERROR, "send_data#tcp_snd_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);546 ntstdio_printf(&ntstdio, "send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 549 547 s->state = STATE_CLOSING; 550 548 break; … … 660 658 len = sizeof(http_content_length) - 1; 661 659 tcp_snd_dat(s->cepid, (void *)http_content_length, len, TMO_FEVR); 662 ntstdio_snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len);663 tcp_snd_dat(s->cepid, (void *)s->temp, ntlibc_strlen(s->temp), TMO_FEVR);660 len = ntstdio_snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len); 661 tcp_snd_dat(s->cepid, (void *)s->temp, len, TMO_FEVR); 664 662 } 665 663 … … 706 704 break; 707 705 case OUT_STATE_WAIT_POST_BODY: 706 //ntstdio_printf(&ntstdio, "wait post body\n"); 708 707 s->out.wait = true; 709 708 break; 710 709 case OUT_STATE_BODY_RECEIVED: 710 //ntstdio_printf(&ntstdio, "body received\n"); 711 711 s->out.statushdr = http_header_200; 712 712 s->out.state = OUT_STATE_SEND_HEADER; 713 713 break; 714 714 case OUT_STATE_SEND_HEADER: 715 //ntstdio_printf(&ntstdio, "send header\n"); 715 716 send_headers(s, s->out.statushdr); 716 717 break; 717 718 case OUT_STATE_SEND_FILE: 719 //ntstdio_printf(&ntstdio, "send file %d\n", s->file.len); 718 720 send_file(s); 719 721 break; 720 722 case OUT_STATE_SEND_DATA: 723 //ntstdio_printf(&ntstdio, "send data %d\n", s->response_len); 721 724 send_data(s); 722 725 break; 723 726 case OUT_STATE_SEND_END: 727 //ntstdio_printf(&ntstdio, "send end\n"); 724 728 s->out.wait = true; 725 729 if (s->message.should_keep_alive && s->reset == 0) { … … 779 783 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 780 784 if (slen < 0) { 781 syslog(LOG_ERROR, "send_ws_data#tcp_get_buf(%s.%d) => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);785 ntstdio_printf(&ntstdio, "send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 782 786 return; 783 787 } … … 843 847 //} 844 848 } 845 syslog(LOG_ERROR, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);849 ntstdio_printf(&ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len); 846 850 uploding = NULL; 847 851 s->state = STATE_CLOSING; … … 851 855 tcp_rel_buf(s->cepid, done); 852 856 if (s->parser.http_errno != HPE_OK) { 853 syslog(LOG_ERROR, "http_parser error %s.%d => %d", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);857 ntstdio_printf(&ntstdio, "http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno); 854 858 uploding = NULL; 855 859 s->state = STATE_CLOSING; … … 876 880 break; 877 881 } 878 syslog(LOG_ERROR, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);882 ntstdio_printf(&ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len); 879 883 s->state = STATE_CLOSING; 880 884 break; … … 932 936 ret2 = get_tim(&httpd_time); 933 937 if (ret2 != E_OK) { 934 syslog(LOG_ERROR, "get_tim");938 ntstdio_printf(&ntstdio, "get_tim\n"); 935 939 return; 936 940 } … … 939 943 case STATE_DISCONNECTED: 940 944 memset(&s->dst, 0, sizeof(s->dst)); 941 if ((ret = TCP_ACP_CEP(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) {942 syslog(LOG_ERROR, "tcp_acp_cep(%d) => %d", s->cepid, ret);943 tslp_tsk(100 ); // TODO945 if ((ret = tcp_acp_cep(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) { 946 ntstdio_printf(&ntstdio, "tcp_acp_cep(%d) => %d\n", s->cepid, ret); 947 tslp_tsk(100 * 1000); // TODO 944 948 s->state = STATE_CLOSING; 945 949 break; … … 974 978 break; 975 979 case STATE_RESET: 976 execute_command(0);980 cmd_execute(command, NULL); 977 981 s->state = STATE_DISCONNECTED; 978 982 break; … … 980 984 981 985 if (s->in.wait && s->out.wait) { 982 tslp_tsk(100 );983 } 984 } 985 } 986 tslp_tsk(100 * 1000); 987 } 988 } 989 }
Note:
See TracChangeset
for help on using the changeset viewer.