ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/tewi/Server/server.c
(Generate patch)

Comparing Server/server.c (file contents):
Revision 1.7 by nishi, Sun Oct 27 23:55:30 2024 UTC vs.
Revision 1.12 by nishi, Sun Nov 3 13:51:52 2024 UTC

# Line 15 | Line 15
15   #include "tw_module.h"
16   #include "tw_version.h"
17  
18 + #ifdef __amiga__
19 + #include <pthread.h>
20 + #endif
21 +
22   #if !defined(_MSC_VER) && !defined(__BORLANDC__)
23   #include <unistd.h>
24   #endif
# Line 107 | Line 111 | uint16_t htons(uint16_t n) { return ((n
111   #endif
112   #endif
113  
114 < #if defined(_PSP) || defined(__ps2sdk__) || defined(__bsdi__)
114 > #if defined(_PSP) || defined(__ps2sdk__) || defined(__bsdi__) || defined(__amiga__)
115   #include "strptime.h"
116   #endif
117  
# Line 344 | Line 348 | void _tw_process_page(SSL* ssl, int sock
348          while(1) {
349                  if(f != NULL) {
350                          char buffer[512];
351 +                        int st;
352                          fread(buffer, size < 512 ? size : 512, 1, f);
353 <                        if(tw_write(ssl, sock, buffer, size < 512 ? size : 512) < 0) return;
353 >                        if((st = tw_write(ssl, sock, buffer, size < 512 ? size : 512)) <= 0) break;
354                  } else {
355 <                        if(tw_write(ssl, sock, (unsigned char*)doc + incr, size < 512 ? size : 512) < 0) return;
355 >                        if(tw_write(ssl, sock, (unsigned char*)doc + incr, size < 512 ? size : 512) <= 0) break;
356                  }
357                  incr += 512;
358                  if(size <= 512) break;
# Line 514 | Line 519 | struct pass_entry {
519   #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
520   #define NO_RETURN_THREAD
521   void tw_server_pass(void* ptr) {
522 + #elif defined(__amiga__)
523 + void* tw_server_pass(void* ptr) {
524   #elif defined(__HAIKU__)
525   int32_t tw_server_pass(void* ptr) {
526   #elif defined(_PSP) || defined(__PPU__)
527   int tw_server_pass(void* ptr) {
528   #endif
529 < #if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
529 > #if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__amiga__)
530   #define FREE_PTR
531          int sock = ((struct pass_entry*)ptr)->sock;
532          bool ssl = ((struct pass_entry*)ptr)->ssl;
# Line 620 | Line 627 | int tw_server_pass(void* ptr) {
627                                          time_t t;
628                                          struct tm* btm;
629                                          strptime(req.headers[i + 1], "%a, %d %b %Y %H:%M:%S GMT", &tm);
630 < #if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__USLC__) || defined(__NeXT__) || defined(__bsdi__)
630 > #if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__) || defined(__ps2sdk__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__USLC__) || defined(__NeXT__) || defined(__bsdi__) || defined(__amiga__) || defined(__sun__)
631                                          t = 0;
632                                          btm = localtime(&t);
633                                          cmtime = mktime(&tm);
# Line 1022 | Line 1029 | void tw_server_loop(void) {
1029          struct timeval tv;
1030   #endif
1031   #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__NETWARE__) && !defined(__DOS__))
1032 <        struct thread_entry threads[2048];
1032 >        struct thread_entry threads[128];
1033          for(i = 0; i < sizeof(threads) / sizeof(threads[0]); i++) {
1034                  threads[i].used = false;
1035          }
# Line 1054 | Line 1061 | void tw_server_loop(void) {
1061                  if(ret == -1) {
1062   #if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
1063                          if(errno == EINTR) continue;
1064 <                        cm_log("Server", "Select failure: %s", strerror(errno));
1064 >                        cm_log("Server", "Select/poll failure: %s", strerror(errno));
1065   #endif
1066                          break;
1067                  } else if(ret == 0) {
# Line 1077 | Line 1084 | void tw_server_loop(void) {
1084                                          SOCKADDR claddr;
1085                                          socklen_t clen = sizeof(claddr);
1086                                          int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen);
1087 < #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
1087 > #if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__amiga__)
1088 > #ifdef __amiga__
1089 >                                        pthread_t thrt;
1090 > #endif
1091                                          int j;
1092                                          struct pass_entry* e = malloc(sizeof(*e));
1093                                          cm_log("Server", "New connection accepted");
# Line 1102 | Line 1112 | void tw_server_loop(void) {
1112   #endif
1113   #elif defined(_PSP) || defined(__PPU__)
1114                                                  tw_server_pass(e);
1115 + #elif defined(__amiga__)
1116 +                                        pthread_create(&thrt, NULL, tw_server_pass, e);
1117   #elif defined(__HAIKU__)
1118                                          for(j = 0; j < sizeof(threads) / sizeof(threads[0]); j++) {
1119                                                  if(threads[j].used) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines