Ignore:
Timestamp:
Jul 6, 2020, 9:22:43 PM (4 years ago)
Author:
coas-nagasima
Message:

ntstdio_snprintfの動作が間違っていたのを修正。
Webサーバーを更新

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/webserver/httpd.c

    r331 r436  
    11/*
    2  *  TOPPERS ECHONET Lite Communication Middleware
     2 *  TOPPERS PROJECT Home Network Working Group Software
    33 *
    4  *  Copyright (C) 2017 Cores Co., Ltd. Japan
     4 *  Copyright (C) 2017-2019 Cores Co., Ltd. Japan
    55 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    6262SYSTIM httpd_time;
    6363struct httpd_state *uploding;
    64 extern char command[256];
    65 
    66 extern int execute_command(int wait);
     64static char command[256];
    6765
    6866/*  TCP 送受信ウィンドバッファ  */
     
    367365
    368366        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"
    370368                        "on last on_body callback call "
    371369                        "but it doesn't! ***\n\n");
     
    405403        struct httpd_state *s = get_context(p);
    406404        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"
    408406                        "value in both on_message_complete and on_headers_complete "
    409407                        "but it doesn't! ***\n\n");
     
    414412                http_body_is_final(p) &&
    415413                !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"
    417415                        "on last on_body callback call "
    418416                        "but it doesn't! ***\n\n");
     
    486484                slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    487485                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);
    489487                        s->state = STATE_CLOSING;
    490488                        break;
     
    499497                len = httpd_fs_read(&s->file, buf, len);
    500498                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);
    502500                        break;
    503501                }
     
    507505
    508506                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);
    510508                        s->state = STATE_CLOSING;
    511509                        break;
     
    529527                slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    530528                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);
    532530                        s->state = STATE_CLOSING;
    533531                        break;
     
    546544
    547545                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);
    549547                        s->state = STATE_CLOSING;
    550548                        break;
     
    660658                len = sizeof(http_content_length) - 1;
    661659                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);
    664662        }
    665663
     
    706704                break;
    707705        case OUT_STATE_WAIT_POST_BODY:
     706                //ntstdio_printf(&ntstdio, "wait post body\n");
    708707                s->out.wait = true;
    709708                break;
    710709        case OUT_STATE_BODY_RECEIVED:
     710                //ntstdio_printf(&ntstdio, "body received\n");
    711711                s->out.statushdr = http_header_200;
    712712                s->out.state = OUT_STATE_SEND_HEADER;
    713713                break;
    714714        case OUT_STATE_SEND_HEADER:
     715                //ntstdio_printf(&ntstdio, "send header\n");
    715716                send_headers(s, s->out.statushdr);
    716717                break;
    717718        case OUT_STATE_SEND_FILE:
     719                //ntstdio_printf(&ntstdio, "send file %d\n", s->file.len);
    718720                send_file(s);
    719721                break;
    720722        case OUT_STATE_SEND_DATA:
     723                //ntstdio_printf(&ntstdio, "send data %d\n", s->response_len);
    721724                send_data(s);
    722725                break;
    723726        case OUT_STATE_SEND_END:
     727                //ntstdio_printf(&ntstdio, "send end\n");
    724728                s->out.wait = true;
    725729                if (s->message.should_keep_alive && s->reset == 0) {
     
    779783        slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    780784        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);
    782786                return;
    783787        }
     
    843847                                //}
    844848                        }
    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);
    846850                        uploding = NULL;
    847851                        s->state = STATE_CLOSING;
     
    851855                tcp_rel_buf(s->cepid, done);
    852856                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);
    854858                        uploding = NULL;
    855859                        s->state = STATE_CLOSING;
     
    876880                                        break;
    877881                                }
    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);
    879883                                s->state = STATE_CLOSING;
    880884                                break;
     
    932936                ret2 = get_tim(&httpd_time);
    933937                if (ret2 != E_OK) {
    934                         syslog(LOG_ERROR, "get_tim");
     938                        ntstdio_printf(&ntstdio, "get_tim\n");
    935939                        return;
    936940                }
     
    939943                case STATE_DISCONNECTED:
    940944                        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);  // TODO
     945                        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
    944948                                s->state = STATE_CLOSING;
    945949                                break;
     
    974978                        break;
    975979                case STATE_RESET:
    976                         execute_command(0);
     980                        cmd_execute(command, NULL);
    977981                        s->state = STATE_DISCONNECTED;
    978982                        break;
     
    980984
    981985                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.