Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 75 75 #include <net/ethernet.h> 76 76 #include <net/net.h> 77 #include <net/net_endian.h> 77 78 #include <net/net_buf.h> 78 #include <net/net_timer.h>79 79 #include <net/net_count.h> 80 80 81 81 #include <netinet/in.h> 82 82 #include <netinet/in_itron.h> 83 #include <netinet/ip.h> 84 #include <netinet/ip6.h> 85 #include <netinet/tcp.h> 86 83 84 #include <netapp/netapp.h> 87 85 #include <netapp/netapp_var.h> 88 86 #include <netapp/wwws.h> … … 118 116 #endif /* of #if NET_COUNT_ENABLE */ 119 117 118 #ifdef USE_TCP_EXTENTIONS 119 120 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 121 122 #if NUM_WWW_SRV_TASKS >= 2 /* 2 を超える個数は想定していない。 */ 123 124 #define WWW4_SRV_TASK WWW_SRV_TASK1 125 #define WWW6_SRV_TASK WWW_SRV_TASK2 126 127 #else /* of #if NUM_WWW_SRV_TASKS >= 2 */ 128 129 #define WWW4_SRV_TASK WWW_SRV_TASK1 130 #define WWW6_SRV_TASK WWW_SRV_TASK1 131 132 #endif /* of #if NUM_WWW_SRV_TASKS >= 2 */ 133 134 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 135 136 #define WWW4_SRV_TASK WWW_SRV_TASK1 137 #define WWW6_SRV_TASK WWW_SRV_TASK1 138 139 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 140 141 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 142 143 120 144 /* 121 145 * 全域変数 … … 161 185 #define ST_NOT_FOUND 1 162 186 187 /* 188 * 接続相手の情報構造体 189 */ 190 191 #ifdef NUM_WWW4_SRV_TASKS 192 #undef NUM_WWW4_SRV_TASKS 193 #endif 194 #define NUM_WWW4_SRV_TASKS 1 195 196 typedef struct t_www_srv_info { 197 ID cepid; /* 通信端点 ID */ 198 ID repid; /* 受付口 ID */ 199 T_IPEP dst; /* 接続相手アドレス情報 */ 200 } T_WWW_SRV_INFO; 201 202 #define INDEX_SRV_INFO(id) ((id)-1) 203 204 #ifdef USE_TCP_EXTENTIONS 205 206 static T_WWW_SRV_INFO www_srv_info[NUM_WWW_SRV_TASKS]; 207 /* 2 を超える個数は想定していない。 */ 208 209 #else /* of #ifdef USE_TCP_EXTENTIONS */ 210 211 static T_WWW_SRV_INFO www_srv_info[] = { 212 213 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 214 215 { WWW4_SRV_CEPID1, WWW4_SRV_REPID }, 216 217 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 218 219 { WWW_SRV_CEPID1, WWW_SRV_REPID }, 220 221 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 222 223 #if NUM_WWW_SRV_TASKS >= 2 /* 2 を超える個数は想定していない。 */ 224 { WWW_SRV_CEPID2, WWW_SRV_REPID }, 225 #endif 226 227 }; 228 229 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 230 163 231 #ifdef USE_COPYSAVE_API 164 232 … … 180 248 if (srbuf->rbuf.index >= srbuf->rbuf.len) { 181 249 if ((error = tcp_rel_buf(cepid, srbuf->rbuf.len)) != E_OK) 182 syslog(LOG_WARNING, "[WWW :%02d] tcp_rel_buf error: %s",250 syslog(LOG_WARNING, "[WWWn:%02u REL] tcp_rel_buf error: %s", 183 251 cepid, itron_strerror(error)); 184 252 srbuf->rbuf.index = 0; 185 253 if ((len = tcp_rcv_buf(cepid, (void**)&srbuf->rbuf.buf, TMO_FEVR)) <= 0) { 186 254 if (len < 0) 187 syslog(LOG_WARNING, "[WWW :%02d] tcp_rcv_buf error: %s",255 syslog(LOG_WARNING, "[WWWn:%02u RCV] tcp_rcv_buf error: %s", 188 256 cepid, itron_strerror(len)); 189 257 srbuf->rbuf.len = 0; … … 228 296 if (srbuf->sbuf.index >= srbuf->sbuf.len) 229 297 if ((error = flush_sbuf(cepid, srbuf)) != E_OK) { 230 syslog(LOG_WARNING, "[WWW :%02d] tcp_snd_daterror: %s", cepid, itron_strerror(error));298 syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error)); 231 299 return 0; 232 300 } … … 234 302 if (srbuf->sbuf.len == 0) { 235 303 if ((blen = tcp_get_buf(cepid, (void**)&srbuf->sbuf.buf, TMO_FEVR)) < 0) { 236 syslog(LOG_WARNING, "[WWW :%02d] tcp_get_buferror: %s", cepid, itron_strerror(srbuf->sbuf.len));304 syslog(LOG_WARNING, "[WWWn:%02u GET] error: %s", cepid, itron_strerror(srbuf->sbuf.len)); 237 305 return 0; 238 306 } … … 272 340 if ((len = tcp_rcv_dat(cepid, srbuf->rbuf.buf, sizeof(srbuf->rbuf.buf), TMO_FEVR)) <= 0) { 273 341 if (len < 0) { 274 syslog(LOG_WARNING, "[WWW :%02d] tcp_rcv_daterror: %s",342 syslog(LOG_WARNING, "[WWWn:%02u RCV] error: %s", 275 343 cepid, itron_strerror(len)); 276 344 } … … 321 389 if (srbuf->sbuf.index >= srbuf->sbuf.len) 322 390 if ((error = flush_sbuf(cepid, srbuf)) != E_OK) { 323 syslog(LOG_WARNING, "[WWW :%02d] tcp_snd_daterror: %s", cepid, itron_strerror(error));391 syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error)); 324 392 return 0; 325 393 } … … 476 544 int_t ix; 477 545 478 for (ix = NUM_FILES; ix -- > 0; ) 546 for (ix = NUM_FILES; ix -- > 0; ) { 479 547 if (!strcmp(file[ix].uri, &line->buf[line->off[1]])) { 548 //syslog(LOG_NOTICE, "[WWWn:%02u PTH] '%s'", cepid, &line->buf[line->off[1]]); 480 549 return (*file[ix].func)(cepid, srbuf); 481 550 } 551 } 482 552 put_status(cepid, srbuf, ST_NOT_FOUND); 483 553 return E_NOEXS; … … 494 564 ER error = E_OK; 495 565 int_t blen = 0; 496 uint16_t len;497 566 498 567 if ((error = tget_mpf(MPF_WWW_LINE, (void*)&method, TMO_FEVR)) != E_OK) { 499 syslog(LOG_CRIT, "[WWW :%02d] get line error: %s.",568 syslog(LOG_CRIT, "[WWWn:%02u MPF] get line error: %s.", 500 569 cepid, itron_strerror(error)); 501 570 return error; 502 571 } 503 572 504 if ( (len = get_line(cepid, method, srbuf)) == 0) {573 if (get_line(cepid, method, srbuf) == 0) { 505 574 if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK) 506 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",575 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 507 576 cepid, itron_strerror(error)); 508 577 return error; … … 510 579 511 580 if ((error = tget_mpf(MPF_WWW_LINE, (void*)&line, TMO_FEVR)) != E_OK) { 512 syslog(LOG_CRIT, "[WWW :%02d] get line buffer error: %s.",581 syslog(LOG_CRIT, "[WWWn:%02u MPF] get line buffer error: %s.", 513 582 cepid, itron_strerror(error)); 514 583 if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK) 515 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",584 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 516 585 cepid, itron_strerror(error)); 517 586 return error; 518 587 } 519 588 520 while ( (len = get_line(cepid, line, srbuf)) > 0) { /* ヘッダをスキップする。*/589 while (get_line(cepid, line, srbuf) > 0) { /* ヘッダをスキップする。*/ 521 590 split_fields(line, ": "); 522 591 if (strcmp("Content-Length", &line->buf[line->off[0]]) == 0) 523 592 blen = atoi(&line->buf[line->off[1]]); 524 593 } 525 while (blen > 0 && (len = get_line(cepid, line, srbuf)) > 0) {594 while (blen > 0 && get_line(cepid, line, srbuf) > 0) { 526 595 /* エンティティ・ボディをスキップする。*/ 527 596 blen -= line->len; … … 529 598 530 599 if ((error = rel_mpf(MPF_WWW_LINE, line)) != E_OK) 531 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",600 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 532 601 cepid, itron_strerror(error)); 533 602 … … 539 608 540 609 if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK) 541 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",610 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 542 611 cepid, itron_strerror(error)); 543 612 … … 567 636 568 637 #ifdef TARGET_KERNEL_ASP 569 "ASP Kernel Release 1.3 (patchlevel = 2)for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"638 "ASP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n" 570 639 #endif 571 640 572 641 #ifdef TARGET_KERNEL_JSP 573 "JSP Kernel Release 1.4 (patchlevel = 3)for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"642 "JSP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n" 574 643 #endif 575 644 576 645 "TINET TCP/IP プロトコルスタックによりサービスしています。<br><hr>\r\n" 646 647 #if NET_COUNT_ENABLE 648 577 649 "<ul><li type=\"square\"><a href=\"stat.html\">ネットワーク統計情報</a></ul><hr>\r\n" 650 651 #else /* of #if NET_COUNT_ENABLE */ 652 653 "<ul><li type=\"square\">ネットワーク統計情報</ul><hr>\r\n" 654 655 #endif /* of #if NET_COUNT_ENABLE */ 656 578 657 "FreeBSD: Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995<br>\r\n" 579 658 "The Regents of the University of California. All rights reserved.<br><br>\r\n" … … 629 708 len += put_str(cepid, srbuf, response); 630 709 get_tim(&finish); 631 syslog(LOG_NOTICE, "[WWW :%02u] send:index.html, len: %4u, time: %lu [ms]",710 syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]", 632 711 cepid, len, (finish - start) * 1000 / SYSTIM_HZ); 633 712 return E_OK; … … 1530 1609 1531 1610 get_tim(&finish); 1532 syslog(LOG_NOTICE, "[WWW :%02u] send:stat.html, len: %4u, time: %lu [ms]",1611 syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html, len: %4u, time: %lu [ms]", 1533 1612 cepid, len, (finish - start) * 1000 / SYSTIM_HZ); 1534 1613 return E_OK; … … 1537 1616 #endif /* of #if NET_COUNT_ENABLE */ 1538 1617 1539 /*1540 * WWW サーバ1541 */1542 1543 static ER1544 www_srv (ID cepid, ID repid)1545 {1546 #if defined(SUPPORT_INET4)1547 1548 T_IPV4EP dst;1549 1550 #endif /* of #if defined(SUPPORT_INET4) */1551 1552 #if defined(SUPPORT_INET6)1553 1554 T_IPV6EP dst;1555 1556 #endif /* of #if defined(SUPPORT_INET6) */1557 1558 T_WWW_RWBUF *srbuf;1559 ER error;1560 SYSTIM time;1561 1562 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {1563 syslog(LOG_WARNING, "[WWW:%02d] accept error: %s", cepid, itron_strerror(error));1564 return error;1565 }1566 1567 get_tim(&time);1568 syslog(LOG_NOTICE, "[WWW:%02u] connected: %6lu, from: %s.%u",1569 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);1570 1571 if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {1572 syslog(LOG_CRIT, "[WWW:%02d] get buffer error: %s.", cepid, itron_strerror(error));1573 srbuf = NULL;1574 }1575 else {1576 srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;1577 1578 #ifdef USE_COPYSAVE_API1579 1580 srbuf->sbuf.len = 0;1581 1582 #else /* of #ifdef USE_COPYSAVE_API */1583 1584 srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);1585 1586 #endif /* of #ifdef USE_COPYSAVE_API */1587 1588 if ((error = parse_request(cepid, srbuf)) != E_OK)1589 syslog(LOG_WARNING, "[WWW:%02d] parse request error: %s",1590 cepid, itron_strerror(error));1591 }1592 1593 if ((error = tcp_sht_cep(cepid)) != E_OK)1594 syslog(LOG_WARNING, "[WWW:%02d] shutdown error: %s", cepid, itron_strerror(error));1595 1596 if (srbuf != NULL) {1597 while (get_char(cepid, srbuf) != EOF)1598 ;1599 if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)1600 syslog(LOG_WARNING, "[WWW:%02d] release buffer error: %s.",1601 cepid, itron_strerror(error));1602 }1603 1604 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)1605 syslog(LOG_WARNING, "[WWW:%02d] close error: %s", cepid, itron_strerror(error));1606 1607 get_tim(&time);1608 syslog(LOG_NOTICE, "[WWW:%02u] finished: %6lu", cepid, time / SYSTIM_HZ);1609 1610 return error;1611 }1612 1613 1618 #ifdef USE_TCP_EXTENTIONS 1614 1619 … … 1616 1621 * get_tcp_rep -- TCP 受付口を獲得する。 1617 1622 */ 1623 1624 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1618 1625 1619 1626 static ER … … 1621 1628 { 1622 1629 ID tskid; 1623 T_TCP_CREP crep; 1630 T_TCP6_CREP crep6; 1631 T_TCP_CREP crep4; 1632 1633 get_tid(&tskid); 1634 if (tskid == WWW4_SRV_TASK) { 1635 crep4.repatr = UINT_C(0); 1636 crep4.myaddr.portno = UINT_C(80); 1637 crep4.myaddr.ipaddr = IPV4_ADDRANY; 1638 return alloc_tcp4_rep(repid, tskid, &crep4); 1639 } 1640 else { 1641 crep6.repatr = UINT_C(0); 1642 crep6.myaddr.portno = UINT_C(80); 1643 memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 1644 return alloc_tcp6_rep(repid, tskid, &crep6); 1645 } 1646 } 1647 1648 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1649 1650 static ER 1651 get_tcp_rep (ID *repid) 1652 { 1653 ID tskid; 1654 T_TCPN_CREP crep; 1624 1655 1625 1656 get_tid(&tskid); … … 1627 1658 crep.repatr = UINT_C(0); 1628 1659 crep.myaddr.portno = UINT_C(80); 1660 1661 #if defined(SUPPORT_INET6) 1662 1663 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 1664 1665 #else /* #if defined(SUPPORT_INET6) */ 1629 1666 1630 1667 #if defined(SUPPORT_INET4) … … 1632 1669 #endif 1633 1670 1634 #if defined(SUPPORT_INET6) 1635 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 1636 #endif 1637 1638 1639 return alloc_tcp_rep(repid, tskid, &crep); 1640 } 1641 1642 /* 1643 * get_tcp_cep -- TCP 通信端点とを獲得する。 1671 #endif /* #if defined(SUPPORT_INET6) */ 1672 1673 return ALLOC_TCP_REP(repid, tskid, &crep); 1674 } 1675 1676 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1677 1678 /* 1679 * get_tcp_cep -- TCP 通信端点を獲得する。 1644 1680 */ 1645 1681 … … 1668 1704 #endif 1669 1705 1670 return alloc_tcp_cep(cepid, tskid, &ccep); 1671 } 1706 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1707 1708 if (tskid == WWW4_SRV_TASK) 1709 return alloc_tcp4_cep(cepid, tskid, &ccep); 1710 else 1711 return alloc_tcp6_cep(cepid, tskid, &ccep); 1712 1713 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1714 1715 return ALLOC_TCP_CEP(cepid, tskid, &ccep); 1716 1717 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1718 1719 } 1720 1721 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1722 1723 /* 1724 * tcp_passive_open -- 受動オープンを実行する。 1725 * 1726 * USE_TCP_NON_BLOCKING OFF 1727 */ 1728 1729 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1730 1731 static ER 1732 tcp_passive_open (T_WWW_SRV_INFO *info, char apip) 1733 { 1734 ER error = E_OK; 1735 T_IPV4EP dst4; 1736 1737 if (apip == API_PROTO_IPV6) { 1738 /* 受付口は IPv6 */ 1739 if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK) 1740 return error; 1741 1742 #ifdef USE_TCP_EXTENTIONS 1743 if ((error = free_tcp6_rep(info->repid, true)) != E_OK) 1744 return error; 1745 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1746 1747 } 1748 else { 1749 /* 受付口は IPv4 */ 1750 if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK) 1751 return error; 1752 in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr); 1753 info->dst.portno = dst4.portno; 1754 1755 #ifdef USE_TCP_EXTENTIONS 1756 if ((error = free_tcp4_rep(info->repid, true)) != E_OK) 1757 return error; 1758 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1759 } 1760 1761 return error; 1762 } 1763 1764 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1765 1766 static ER 1767 tcp_passive_open (T_WWW_SRV_INFO *info, char apip) 1768 { 1769 ER error = E_OK; 1770 1771 if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK) 1772 return error; 1773 1774 #ifdef USE_TCP_EXTENTIONS 1775 if ((error = FREE_TCP_REP(info->repid, true)) != E_OK) 1776 return error; 1777 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1778 1779 return error; 1780 } 1781 1782 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1783 1784 /* 1785 * WWW サーバ 1786 */ 1787 1788 static ER 1789 www_srv (uint_t six, char apip) 1790 { 1791 T_WWW_RWBUF *srbuf; 1792 ER error; 1793 SYSTIM now; 1794 1795 if ((error = tcp_passive_open(&www_srv_info[six], apip)) != E_OK) 1796 return error; 1797 1798 syscall(get_tim(&now)); 1799 1800 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 1801 1802 if (apip == API_PROTO_IPV6) 1803 syslog(LOG_NOTICE, "[WWW6:%02u ACP] conct: %6lu,from: %s.%u", 1804 www_srv_info[six].cepid, now / SYSTIM_HZ, 1805 ipv62str(NULL, &www_srv_info[six].dst.ipaddr), 1806 www_srv_info[six].dst.portno); 1807 else 1808 syslog(LOG_NOTICE, "[WWW4:%02u ACP] conct: %6lu,from: %s.%u", 1809 www_srv_info[six].cepid, now / SYSTIM_HZ, 1810 ip2str(NULL, &www_srv_info[six].dst.ipaddr.s6_addr32[3]), 1811 www_srv_info[six].dst.portno); 1812 1813 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1814 1815 syslog(LOG_NOTICE, "[WWWn:%02u ACP] conct: %6lu,from: %s.%u", 1816 www_srv_info[six].cepid, now / SYSTIM_HZ, 1817 IP2STR(NULL, &www_srv_info[six].dst.ipaddr), 1818 www_srv_info[six].dst.portno); 1819 1820 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1821 1822 if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) { 1823 syslog(LOG_CRIT, "[WWWn:%02u MPF] get buffer error: %s.", 1824 www_srv_info[six].cepid, itron_strerror(error)); 1825 srbuf = NULL; 1826 } 1827 else { 1828 srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0; 1829 1830 #ifdef USE_COPYSAVE_API 1831 1832 srbuf->sbuf.len = 0; 1833 1834 #else /* of #ifdef USE_COPYSAVE_API */ 1835 1836 srbuf->sbuf.len = sizeof(srbuf->sbuf.buf); 1837 1838 #endif /* of #ifdef USE_COPYSAVE_API */ 1839 1840 if ((error = parse_request(www_srv_info[six].cepid, srbuf)) != E_OK) 1841 syslog(LOG_WARNING, "[WWWn:%02u RCV] parse request error: %s", 1842 www_srv_info[six].cepid, itron_strerror(error)); 1843 } 1844 1845 if ((error = tcp_sht_cep(www_srv_info[six].cepid)) != E_OK) 1846 syslog(LOG_WARNING, "[WWWn:%02u SHD] shutdown error: %s", 1847 www_srv_info[six].cepid, itron_strerror(error)); 1848 1849 if (srbuf != NULL) { 1850 while (get_char(www_srv_info[six].cepid, srbuf) != EOF) 1851 ; 1852 if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK) 1853 syslog(LOG_WARNING, "[WWWn:%02u REL] release buffer error: %s.", 1854 www_srv_info[six].cepid, itron_strerror(error)); 1855 } 1856 1857 if ((error = tcp_cls_cep(www_srv_info[six].cepid, TMO_FEVR)) != E_OK) 1858 syslog(LOG_WARNING, "[WWWn:%02u CLS] close error: %s", 1859 www_srv_info[six].cepid, itron_strerror(error)); 1860 1861 get_tim(&now); 1862 syslog(LOG_NOTICE, "[WWWn:%02u FIN] finsh: %6lu", 1863 www_srv_info[six].cepid, now / SYSTIM_HZ); 1864 1865 return error; 1866 } 1867 1868 #ifdef USE_TCP_EXTENTIONS 1672 1869 1673 1870 /* … … 1678 1875 www_srv_task(intptr_t exinf) 1679 1876 { 1680 ID tskid , cepid, repid;1877 ID tskid; 1681 1878 ER error = E_OK; 1879 uint_t six; 1880 char apip; 1682 1881 1683 1882 syscall(get_tid(&tskid)); 1684 syslog(LOG_NOTICE, "[WWW:%d] started.", tskid); 1883 six = INDEX_SRV_INFO((ID)exinf); 1884 1885 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 1886 1887 if (six >= NUM_WWW4_SRV_TASKS) 1888 apip = API_PROTO_IPV6; 1889 else 1890 apip = API_PROTO_IPV4; 1891 1892 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1893 1894 apip = API_PROTO_IPVn; 1895 1896 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1897 1898 syslog(LOG_NOTICE, "[WWW%c:%d] started.", apip, tskid); 1685 1899 while (true) { 1686 1900 1687 1901 syscall(slp_tsk()); 1688 if ((error = get_tcp_cep (&cepid)) != E_OK) { 1689 syslog(LOG_NOTICE, "[WWW:00 EXT] CEP create error: %s", itron_strerror(error)); 1902 if ((error = get_tcp_cep(&www_srv_info[six].cepid)) != E_OK) { 1903 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create CEP error: %s", 1904 apip, www_srv_info[six].cepid, itron_strerror(error)); 1690 1905 continue; 1691 1906 } 1692 1907 1693 if ((error = get_tcp_rep (&repid)) != E_OK) { 1694 syslog(LOG_NOTICE, "[WWW:00 EXT] REP create error: %s", itron_strerror(error)); 1695 free_tcp_cep(cepid); 1696 continue; 1697 } 1698 1699 while (true) 1700 if ((error = www_srv(cepid, repid)) != E_OK) { 1701 error = free_tcp_rep(repid, error != E_DLT); 1908 while (true) { 1909 1910 if ((error = get_tcp_rep(&www_srv_info[six].repid)) != E_OK) { 1911 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create REP error: %02u, %s", 1912 apip, www_srv_info[six].cepid, www_srv_info[six].repid, itron_strerror(error)); 1702 1913 break; 1703 1914 } 1704 1705 if ((error = free_tcp_cep(cepid)) != E_OK) 1706 syslog(LOG_NOTICE, "[WWW:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error)); 1707 1708 } 1915 else if ((error = www_srv(six, apip)) != E_OK) { 1916 1917 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1918 1919 if (tskid == WWW4_SRV_TASK) 1920 error = free_tcp4_rep(www_srv_info[six].repid, error != E_DLT); 1921 else 1922 error = free_tcp6_rep(www_srv_info[six].repid, error != E_DLT); 1923 1924 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1925 1926 error = FREE_TCP_REP(www_srv_info[six].repid, error != E_DLT); 1927 1928 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1929 1930 if (error != E_OK) { 1931 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete REP error: %02u, %s", 1932 apip, www_srv_info[six].cepid, 1933 www_srv_info[six].repid, itron_strerror(error)); 1934 1935 } 1936 break; 1937 } 1938 } 1939 1940 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1941 1942 if (tskid == WWW4_SRV_TASK) { 1943 if ((error = free_tcp4_cep(www_srv_info[six].cepid)) != E_OK) 1944 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s", 1945 apip, www_srv_info[six].cepid, itron_strerror(error)); 1946 } 1947 else { 1948 if ((error = free_tcp6_cep(www_srv_info[six].cepid)) != E_OK) 1949 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s", 1950 apip, www_srv_info[six].cepid, itron_strerror(error)); 1951 } 1952 1953 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1954 1955 if ((error = FREE_TCP_CEP(www_srv_info[six].cepid)) != E_OK) 1956 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s", 1957 apip, www_srv_info[six].cepid, itron_strerror(error)); 1958 1959 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1960 1961 } 1962 } 1963 1964 /* 1965 * wakeup_www_srv -- WWW サーバタスクの休止解除 1966 */ 1967 1968 ER 1969 wakeup_www_srv (char apip) 1970 { 1971 ID taskid; 1972 1973 if (apip == API_PROTO_IPV6) 1974 taskid = WWW6_SRV_TASK; 1975 else 1976 taskid = WWW4_SRV_TASK; 1977 syslog(LOG_NOTICE, "[WWW%c(EXT):%d] wake up.", apip, taskid); 1978 return wup_tsk(taskid); 1709 1979 } 1710 1980 … … 1718 1988 www_srv_task(intptr_t exinf) 1719 1989 { 1720 ID tskid; 1990 ID tskid, cepid; 1991 uint_t six; 1992 char apip; 1721 1993 1722 1994 get_tim(&srv_start); 1723 1995 get_tid(&tskid); 1724 syslog(LOG_NOTICE, "[WWW:%d,%d] started.", tskid, (int_t)exinf); 1996 six = INDEX_SRV_INFO((ID)exinf); 1997 cepid = www_srv_info[INDEX_SRV_INFO((ID)exinf)].cepid; 1998 1999 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 2000 2001 if (six >= NUM_WWW4_SRV_TASKS) 2002 apip = API_PROTO_IPV6; 2003 else 2004 apip = API_PROTO_IPV4; 2005 2006 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 2007 2008 apip = API_PROTO_IPVn; 2009 2010 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 2011 2012 syslog(LOG_NOTICE, "[WWW%c SRV:%d,%d] started.", apip, tskid, cepid); 2013 1725 2014 while (true) { 1726 while (www_srv( (int_t)exinf, WWW_SRV_REPID) == E_OK)2015 while (www_srv(six, apip) == E_OK) 1727 2016 ; 1728 2017 }
Note:
See TracChangeset
for help on using the changeset viewer.