Lines Matching refs:host

104 PRIVATE BOOL isLastInPipe (HTHost * host, HTNet * net)  in isLastInPipe()  argument
106 return HTList_lastObject(host->pipeline) == net; in isLastInPipe()
109 PRIVATE BOOL killPipeline (HTHost * host, HTEventType type) in killPipeline() argument
111 if (host) { in killPipeline()
112 int piped = HTList_count(host->pipeline); in killPipeline()
113 int pending = HTList_count(host->pending); in killPipeline()
120 HTNet * net = HTList_removeLastObject(host->pending); in killPipeline()
124 (*net->event.cbf)(HTChannel_socket(host->channel), net->event.param, type); in killPipeline()
125 if (host->lock == net) host->lock = NULL; in killPipeline()
136 HTNet * net = HTList_firstObject(host->pipeline); in killPipeline()
140 (*net->event.cbf)(HTChannel_socket(host->channel), net->event.param, type); in killPipeline()
146 HTChannel_setSemaphore(host->channel, 0); in killPipeline()
147 HTHost_clearChannel(host, HT_INTERRUPTED); in killPipeline()
160 HTHost * host = (HTHost *) param; in IdleTimeoutEvent() local
161 SOCKET sockfd = HTChannel_socket(host->channel); in IdleTimeoutEvent()
164 host->timer = NULL; in IdleTimeoutEvent()
166 return HostEvent (sockfd, host, HTEvent_CLOSE); in IdleTimeoutEvent()
177 HTHost * host = (HTHost *)pVoid; in HostEvent() local
190 if (HTChannel_socket(host->channel) != soc && type != HTEvent_ACCEPT && !host->listening) { in HostEvent()
193 HTChannel_socket(host->channel)); in HostEvent()
197 targetNet = (HTNet *)HTList_firstObject(host->pipeline); in HostEvent()
201 if ((ret = (*targetNet->event.cbf)(HTChannel_socket(host->channel), in HostEvent()
205 if (targetNet == NULL && host->remainingRead > 0) { in HostEvent()
207 host->remainingRead); in HostEvent()
208 host->remainingRead = 0; in HostEvent()
214 } while (host->remainingRead > 0); in HostEvent()
222 host _ host->hostname); in HostEvent()
229 if (HTChannel_socket(host->channel) != INVSOC) { in HostEvent()
230 while ((ret = NETREAD(HTChannel_socket(host->channel), buf, sizeof(buf)-1)) > 0) { in HostEvent()
232 host _ host->hostname _ ret _ buf); in HostEvent()
237 HTHost_clearChannel(host, HT_OK); in HostEvent()
241 HTNet * targetNet = (HTNet *)HTList_lastObject(host->pipeline); in HostEvent()
245 return (*targetNet->event.cbf)(HTChannel_socket(host->channel), targetNet->event.param, type); in HostEvent()
248 host _ in HostEvent()
249 host ? host->hostname : "<null>" _ in HostEvent()
251 host ? host->reqsMade : -1 _ in HostEvent()
252 HTList_count(host->pipeline) _ in HostEvent()
253 HTList_count(host->pending)); in HostEvent()
256 host _ host ? host->hostname : "<null>" _ type); in HostEvent()
262 killPipeline(host, HTEvent_TIMEOUT); in HostEvent()
265 host->hostname); in HostEvent()
281 PUBLIC HTHost * HTHost_new (char * host, u_short u_port) in HTHost_new() argument
286 if (!host) { in HTHost_new()
294 for (ptr=host; *ptr; ptr++) in HTHost_new()
309 if (!strcmp(pres->hostname, host) && u_port == pres->u_port) { in HTHost_new()
346 StrAllocCopy(pres->hostname, host); in HTHost_new()
358 host _ pres _ list); in HTHost_new()
425 PUBLIC HTHost * HTHost_find (char * host) in HTHost_find() argument
429 HTTRACE(CORE_TRACE, "Host info... Looking for `%s\'\n" _ host ? host : "<null>"); in HTHost_find()
432 if (host && HostTable) { in HTHost_find()
435 for (ptr=host; *ptr; ptr++) in HTHost_find()
444 if (!strcmp(pres->hostname, host)) { in HTHost_find()
450 HTTRACE(CORE_TRACE, "Host info... Found `%s\'\n" _ host); in HTHost_find()
466 HTHost * host; in HTHost_deleteAll() local
476 while ((host = (HTHost *) HTList_removeFirstObject(list)) != NULL) in HTHost_deleteAll()
477 free_object(host); in HTHost_deleteAll()
489 PUBLIC char * HTHost_name (HTHost * host) in HTHost_name() argument
491 return host ? host->hostname : NULL; in HTHost_name()
497 PUBLIC char * HTHost_class (HTHost * host) in HTHost_class() argument
499 return host ? host->type : NULL; in HTHost_class()
502 PUBLIC void HTHost_setClass (HTHost * host, char * s_class) in HTHost_setClass() argument
504 if (host && s_class) StrAllocCopy(host->type, s_class); in HTHost_setClass()
510 PUBLIC int HTHost_version (HTHost *host) in HTHost_version() argument
512 return host ? host->version : 0; in HTHost_version()
515 PUBLIC void HTHost_setVersion (HTHost * host, int version) in HTHost_setVersion() argument
517 if (host) host->version = version; in HTHost_setVersion()
558 PUBLIC void HTHost_setPersistExpires (HTHost * host, time_t expires) in HTHost_setPersistExpires() argument
560 if (host) host->expires = expires; in HTHost_setPersistExpires()
563 PUBLIC time_t HTHost_persistExpires (HTHost * host) in HTHost_persistExpires() argument
565 return host ? host->expires : -1; in HTHost_persistExpires()
568 PUBLIC void HTHost_setReqsPerConnection (HTHost * host, int reqs) in HTHost_setReqsPerConnection() argument
570 if (host) host->reqsPerConnection = reqs; in HTHost_setReqsPerConnection()
573 PUBLIC int HTHost_reqsPerConnection (HTHost * host) in HTHost_reqsPerConnection() argument
575 return host ? host->reqsPerConnection : -1; in HTHost_reqsPerConnection()
578 PUBLIC void HTHost_setReqsMade (HTHost * host, int reqs) in HTHost_setReqsMade() argument
580 if (host) host->reqsMade = reqs; in HTHost_setReqsMade()
583 PUBLIC int HTHost_reqsMade (HTHost * host) in HTHost_reqsMade() argument
585 return host ? host->reqsMade : -1; in HTHost_reqsMade()
609 PUBLIC char * HTHost_server (HTHost * host) in HTHost_server() argument
611 return host ? host->server : NULL; in HTHost_server()
614 PUBLIC BOOL HTHost_setServer (HTHost * host, const char * server) in HTHost_setServer() argument
616 if (host && server) { in HTHost_setServer()
617 StrAllocCopy(host->server, server); in HTHost_setServer()
626 PUBLIC char * HTHost_userAgent (HTHost * host) in HTHost_userAgent() argument
628 return host ? host->user_agent : NULL; in HTHost_userAgent()
631 PUBLIC BOOL HTHost_setUserAgent (HTHost * host, const char * userAgent) in HTHost_setUserAgent() argument
633 if (host && userAgent) { in HTHost_setUserAgent()
634 StrAllocCopy(host->user_agent, userAgent); in HTHost_setUserAgent()
643 PUBLIC char * HTHost_rangeUnits (HTHost * host) in HTHost_rangeUnits() argument
645 return host ? host->range_units : NULL; in HTHost_rangeUnits()
648 PUBLIC BOOL HTHost_setRangeUnits (HTHost * host, const char * units) in HTHost_setRangeUnits() argument
650 if (host && units) { in HTHost_setRangeUnits()
651 StrAllocCopy(host->range_units, units); in HTHost_setRangeUnits()
663 PUBLIC BOOL HTHost_isRangeUnitAcceptable (HTHost * host, const char * unit) in HTHost_isRangeUnitAcceptable() argument
665 if (host && unit) { in HTHost_isRangeUnitAcceptable()
667 if (host->range_units) { in HTHost_isRangeUnitAcceptable()
668 char * start = HTStrCaseStr(host->range_units, "none"); in HTHost_isRangeUnitAcceptable()
692 PUBLIC BOOL HTHost_setPersistent (HTHost * host, in HTHost_setPersistent() argument
696 if (!host) return NO; in HTHost_setPersistent()
706 host->persistent = NO; in HTHost_setPersistent()
707 return HTHost_clearChannel(host, HT_IGNORE); in HTHost_setPersistent()
714 HTHost_setMode(host, mode); in HTHost_setPersistent()
715 if (!host->persistent) { in HTHost_setPersistent()
716 SOCKET sockfd = HTChannel_socket(host->channel); in HTHost_setPersistent()
718 host->persistent = YES; in HTHost_setPersistent()
719 host->expires = time(NULL) + HTPassiveTimeout; /* Default timeout */ in HTHost_setPersistent()
720 HTChannel_setHost(host->channel, host); in HTHost_setPersistent()
722 HTTRACE(CORE_TRACE, "Host info... added host %p as persistent\n" _ host); in HTHost_setPersistent()
730 HTTRACE(CORE_TRACE, "Host info... %p already persistent\n" _ host); in HTHost_setPersistent()
739 PUBLIC BOOL HTHost_isPersistent (HTHost * host) in HTHost_isPersistent() argument
741 return host && host->persistent; in HTHost_isPersistent()
747 PUBLIC HTChannel * HTHost_channel (HTHost * host) in HTHost_channel() argument
749 return host ? host->channel : NULL; in HTHost_channel()
757 PUBLIC BOOL HTHost_setCloseNotification (HTHost * host, BOOL mode) in HTHost_setCloseNotification() argument
759 if (host) { in HTHost_setCloseNotification()
760 host->close_notification = mode; in HTHost_setCloseNotification()
766 PUBLIC BOOL HTHost_closeNotification (HTHost * host) in HTHost_closeNotification() argument
768 return host && host->close_notification; in HTHost_closeNotification()
775 PUBLIC BOOL HTHost_clearChannel (HTHost * host, int status) in HTHost_clearChannel() argument
777 if (host && host->channel) { in HTHost_clearChannel()
778 HTChannel_setHost(host->channel, NULL); in HTHost_clearChannel()
780 HTEvent_unregister(HTChannel_socket(host->channel), HTEvent_READ); in HTHost_clearChannel()
781 HTEvent_unregister(HTChannel_socket(host->channel), HTEvent_WRITE); in HTHost_clearChannel()
782 host->registeredFor = 0; in HTHost_clearChannel()
789 HTChannel_delete(host->channel, status); in HTHost_clearChannel()
790 host->expires = 0; in HTHost_clearChannel()
791 host->channel = NULL; in HTHost_clearChannel()
792 host->tcpstate = TCP_BEGIN; in HTHost_clearChannel()
793 host->reqsMade = 0; in HTHost_clearChannel()
794 if (HTHost_isPersistent(host)) { in HTHost_clearChannel()
796 host->persistent = NO; in HTHost_clearChannel()
798 host->close_notification = NO; in HTHost_clearChannel()
799 host->broken_pipe = NO; in HTHost_clearChannel()
800 host->mode = HT_TP_SINGLE; in HTHost_clearChannel()
802 host->recovered = 0; in HTHost_clearChannel()
804 HTTRACE(CORE_TRACE, "Host info... removed host %p as persistent\n" _ host); in HTHost_clearChannel()
806 if (!HTList_isEmpty(host->pending)) { in HTHost_clearChannel()
807 …HTTRACE(CORE_TRACE, "Host has %d object(s) pending - attempting launch\n" _ HTList_count(host->pen… in HTHost_clearChannel()
808 HTHost_launchPending(host); in HTHost_clearChannel()
815 PUBLIC BOOL HTHost_doRecover (HTHost * host) in HTHost_doRecover() argument
817 return host ? host->do_recover : NO; in HTHost_doRecover()
824 PUBLIC BOOL HTHost_recoverPipe (HTHost * host) in HTHost_recoverPipe() argument
826 if (host) { in HTHost_recoverPipe()
827 int piped = HTList_count(host->pipeline); in HTHost_recoverPipe()
832 if (host->recovered > MAX_HOST_RECOVER) { in HTHost_recoverPipe()
833 …HTTRACE(CORE_TRACE, "Host recover %p already %d times - not doing it anymore\n" _ host _ host->rec… in HTHost_recoverPipe()
843 host->recovered++; in HTHost_recoverPipe()
844 …d %d times. Moving %d Net objects from pipe line to pending queue\n" _ host _ host->recovered _ pi… in HTHost_recoverPipe()
849 HTEvent_unregister(HTChannel_socket(host->channel), HTEvent_READ); in HTHost_recoverPipe()
850 HTEvent_unregister(HTChannel_socket(host->channel), HTEvent_WRITE); in HTHost_recoverPipe()
851 host->registeredFor = 0; in HTHost_recoverPipe()
856 host->mode = HT_TP_SINGLE; in HTHost_recoverPipe()
861 if (!host->pending) host->pending = HTList_new(); in HTHost_recoverPipe()
863 HTNet * net = HTList_removeLastObject(host->pipeline); in HTHost_recoverPipe()
866 (*net->event.cbf)(HTChannel_socket(host->channel), net->event.param, HTEvent_RESET); in HTHost_recoverPipe()
867 HTList_appendObject(host->pending, net); in HTHost_recoverPipe()
868 host->lock = net; in HTHost_recoverPipe()
871 HTChannel_setSemaphore(host->channel, 0); in HTHost_recoverPipe()
872 HTHost_clearChannel(host, HT_INTERRUPTED); in HTHost_recoverPipe()
873 host->do_recover = NO; in HTHost_recoverPipe()
884 PUBLIC BOOL HTHost_killPipe (HTHost * host) in HTHost_killPipe() argument
886 return killPipeline(host, HTEvent_CLOSE); in HTHost_killPipe()
893 PUBLIC HTTransportMode HTHost_mode (HTHost * host, BOOL * active) in HTHost_mode() argument
895 return host ? host->mode : HT_TP_SINGLE; in HTHost_mode()
904 PUBLIC BOOL HTHost_setMode (HTHost * host, HTTransportMode mode) in HTHost_setMode() argument
906 if (host) { in HTHost_setMode()
910 if (mode == HT_TP_SINGLE && host->mode > mode) { in HTHost_setMode()
911 int piped = HTList_count(host->pipeline); in HTHost_setMode()
915 if (!host->pending) host->pending = HTList_new(); in HTHost_setMode()
917 HTNet * net = HTList_removeLastObject(host->pipeline); in HTHost_setMode()
919 (*net->event.cbf)(HTChannel_socket(host->channel), net->event.param, HTEvent_RESET); in HTHost_setMode()
920 HTList_appendObject(host->pending, net); in HTHost_setMode()
922 HTChannel_setSemaphore(host->channel, 0); in HTHost_setMode()
923 HTHost_clearChannel(host, HT_INTERRUPTED); in HTHost_setMode()
931 if (mode == HT_TP_PIPELINE && host->recovered > MAX_HOST_RECOVER) { in HTHost_setMode()
933 host); in HTHost_setMode()
935 host->mode = mode; in HTHost_setMode()
936 HTTRACE(PROT_TRACE, "Host info... New mode is %d for host %p\n" _ host->mode _ host); in HTHost_setMode()
949 PUBLIC BOOL HTHost_isIdle (HTHost * host) in HTHost_isIdle() argument
951 return (host && HTList_isEmpty(host->pipeline)); in HTHost_isIdle()
954 PRIVATE BOOL _roomInPipe (HTHost * host) in _roomInPipe() argument
957 if (!host || in _roomInPipe()
958 (host->reqsPerConnection && host->reqsMade >= host->reqsPerConnection) || in _roomInPipe()
959 HTHost_closeNotification(host) || host->broken_pipe) in _roomInPipe()
961 count = HTList_count(host->pipeline); in _roomInPipe()
962 switch (host->mode) { in _roomInPipe()
966 return (host->recovered < MAX_HOST_RECOVER) ? in _roomInPipe()
980 PUBLIC int HTHost_addNet (HTHost * host, HTNet * net) in HTHost_addNet() argument
982 if (host && net) { in HTHost_addNet()
984 BOOL doit = (host->doit==net); in HTHost_addNet()
990 if (!host->channel && HTNet_availableSockets() <= 0) { in HTHost_addNet()
996 if (HTList_indexOf(PendHost, host) < 0) HTList_addObject(PendHost, host); in HTHost_addNet()
1003 if (!host->pending) host->pending = HTList_new(); in HTHost_addNet()
1004 if (host->lock == net) in HTHost_addNet()
1005 HTList_appendObject(host->pending, net); in HTHost_addNet()
1007 HTList_addObject(host->pending, net); in HTHost_addNet()
1010 net _ net->request _ host _ host->reqsMade _ in HTHost_addNet()
1011 HTList_count(host->pipeline) _ HTList_count(host->pending)); in HTHost_addNet()
1021 if (HTList_indexOf(host->pipeline, net) >= 0) { in HTHost_addNet()
1024 net _ net->request _ host->reqsMade _ in HTHost_addNet()
1025 HTList_count(host->pipeline) _ in HTHost_addNet()
1026 HTList_count(host->pending)); in HTHost_addNet()
1032 if (HTList_indexOf(host->pending, net) >= 0) { in HTHost_addNet()
1035 net _ net->request _ host->reqsMade _ in HTHost_addNet()
1036 HTList_count(host->pipeline) _ in HTHost_addNet()
1037 HTList_count(host->pending)); in HTHost_addNet()
1048 if (_roomInPipe(host) && (HTList_isEmpty(host->pending) || doit)) { in HTHost_addNet()
1049 if (doit) host->doit = NULL; in HTHost_addNet()
1050 if (!host->pipeline) host->pipeline = HTList_new(); in HTHost_addNet()
1051 HTList_addObject(host->pipeline, net); in HTHost_addNet()
1052 host->reqsMade++; in HTHost_addNet()
1054 net _ net->request _ host _ host->reqsMade _ in HTHost_addNet()
1055 HTList_count(host->pipeline) _ HTList_count(host->pending)); in HTHost_addNet()
1060 if (host->timer) { in HTHost_addNet()
1061 HTTimer_delete(host->timer); in HTHost_addNet()
1062 host->timer = NULL; in HTHost_addNet()
1072 if (!host->pending) host->pending = HTList_new(); in HTHost_addNet()
1073 HTList_addObject(host->pending, net); in HTHost_addNet()
1076 host _ host->reqsMade _ in HTHost_addNet()
1077 HTList_count(host->pipeline) _ HTList_count(host->pending)); in HTHost_addNet()
1085 PRIVATE BOOL HTHost_free (HTHost * host, int status) in HTHost_free() argument
1087 if (host->channel) { in HTHost_free()
1090 if (HTHost_isPersistent(host)) { in HTHost_free()
1091 int piped = HTList_count(host->pipeline); in HTHost_free()
1092 if (HTHost_closeNotification(host)) { in HTHost_free()
1094 HTChannel_socket(host->channel)); in HTHost_free()
1101 host->reqsPerConnection = host->reqsMade - piped; in HTHost_free()
1103 host->reqsMade _ piped _ host->reqsPerConnection); in HTHost_free()
1104 host->do_recover = YES; in HTHost_free()
1107 if (HTChannel_delete(host->channel, status)) { in HTHost_free()
1108 HTTRACE(CORE_TRACE, "Host Event.. clearing channel on host %p (%s)\n" _ host _ host->hostname); in HTHost_free()
1109 host->channel = NULL; in HTHost_free()
1112 HTChannel_setSemaphore(host->channel, 0); in HTHost_free()
1113 HTHost_clearChannel(host, status); in HTHost_free()
1115 } else if (piped<=1 && host->reqsMade==host->reqsPerConnection) { in HTHost_free()
1117 HTChannel_socket(host->channel)); in HTHost_free()
1123 HTChannel_setSemaphore(host->channel, 0); in HTHost_free()
1124 HTHost_clearChannel(host, status); in HTHost_free()
1128 HTChannel_socket(host->channel)); in HTHost_free()
1129 if (HTChannel_delete(host->channel, status)) { in HTHost_free()
1130 …HTDEBUGBREAK("Host Event.. Channel unexpected deleted from host %p (%s)\n" _ host _ host->hostname… in HTHost_free()
1131 host->channel = NULL; in HTHost_free()
1137 if (piped<=1 && HTList_isEmpty(host->pending) && !host->timer) { in HTHost_free()
1138 host->timer = HTTimer_new(NULL, IdleTimeoutEvent, in HTHost_free()
1139 host, HTActiveTimeout, YES, NO); in HTHost_free()
1140 HTTRACE(PROT_TRACE, "Host........ Object %p going idle...\n" _ host); in HTHost_free()
1145 … HTTRACE(CORE_TRACE, "Host Object. closing socket %d\n" _ HTChannel_socket(host->channel)); in HTHost_free()
1146 HTChannel_setSemaphore(host->channel, 0); in HTHost_free()
1147 HTHost_clearChannel(host, status); in HTHost_free()
1153 PUBLIC BOOL HTHost_deleteNet (HTHost * host, HTNet * net, int status) in HTHost_deleteNet() argument
1155 if (host && net) { in HTHost_deleteNet()
1159 if (host->pipeline && HTList_indexOf(host->pipeline, net) >= 0) { in HTHost_deleteNet()
1160 HTHost_free(host, status); in HTHost_deleteNet()
1161 HTList_removeObjectAll(host->pipeline, net); in HTHost_deleteNet()
1164 HTList_removeObjectAll(host->pending, net); /* just to make sure */ in HTHost_deleteNet()
1165 host->lock = HTList_firstObject(host->pending); in HTHost_deleteNet()
1185 PUBLIC HTNet * HTHost_nextPendingNet (HTHost * host) in HTHost_nextPendingNet() argument
1188 if (host && host->pending) { in HTHost_nextPendingNet()
1192 if ((net = (HTNet *) HTList_removeFirstObject(host->pending)) != NULL) { in HTHost_nextPendingNet()
1194 net _ host); in HTHost_nextPendingNet()
1202 host->doit = net; in HTHost_nextPendingNet()
1213 HTHost * host = NULL; in HTHost_nextPendingHost() local
1215 if ((host = (HTHost *) HTList_removeFirstObject(PendHost)) != NULL) in HTHost_nextPendingHost()
1217 host); in HTHost_nextPendingHost()
1219 return host; in HTHost_nextPendingHost()
1227 PUBLIC BOOL HTHost_launchPending (HTHost * host) in HTHost_launchPending() argument
1230 if (!host) { in HTHost_launchPending()
1240 if (host->mode == HT_TP_PIPELINE) { in HTHost_launchPending()
1241 net = (HTNet *) HTList_lastObject(host->pipeline); in HTHost_launchPending()
1249 if (_roomInPipe(host) && DoPendingReqLaunch && in HTHost_launchPending()
1250 (net = HTHost_nextPendingNet(host))) { in HTHost_launchPending()
1253 net _ HTList_count(host->pipeline) _ host->reqsMade); in HTHost_launchPending()
1265 host->reqsMade++; in HTHost_launchPending()
1275 PUBLIC HTNet * HTHost_firstNet (HTHost * host) in HTHost_firstNet() argument
1277 return (HTNet *) HTList_firstObject(host->pipeline); in HTHost_firstNet()
1280 PUBLIC int HTHost_numberOfOutstandingNetObjects (HTHost * host) in HTHost_numberOfOutstandingNetObjects() argument
1282 return host ? HTList_count(host->pipeline) : -1; in HTHost_numberOfOutstandingNetObjects()
1285 PUBLIC int HTHost_numberOfPendingNetObjects (HTHost * host) in HTHost_numberOfPendingNetObjects() argument
1287 return host ? HTList_count(host->pending) : -1; in HTHost_numberOfPendingNetObjects()
1296 PUBLIC int HTHost_connect (HTHost * host, HTNet * net, char * url) in HTHost_connect() argument
1300 if (!host) { in HTHost_connect()
1302 if ((host = HTHost_newWParse(request, url, HTProtocol_id(protocol))) == NULL) in HTHost_connect()
1310 if (!host->lock && !host->channel) { in HTHost_connect()
1312 host->forceWriteFlush = YES; in HTHost_connect()
1313 host->lock = (next_pending = HTList_firstObject(host->pending)) ? in HTHost_connect()
1315 HTTRACE(CORE_TRACE, "Host connect Grabbing lock on Host %p with %p\n" _ host _ host->lock); in HTHost_connect()
1317 HTNet_setHost(net, host); in HTHost_connect()
1320 if (!host->lock || (host->lock && host->lock == net)) { in HTHost_connect()
1325 host->lock = net; in HTHost_connect()
1334 if ((next_pending = HTList_firstObject(host->pending))) { in HTHost_connect()
1336 host _ next_pending); in HTHost_connect()
1337 host->lock = next_pending; in HTHost_connect()
1339 HTTRACE(CORE_TRACE, "Host connect Unlocking Host %p\n" _ host); in HTHost_connect()
1340 host->lock = NULL; in HTHost_connect()
1345 HTTRACE(CORE_TRACE, "Host connect Host %p already locked with %p\n" _ host _ host->lock); in HTHost_connect()
1346 if ((status = HTHost_addNet(host, net)) == HT_PENDING) { in HTHost_connect()
1353 PUBLIC int HTHost_listen (HTHost * host, HTNet * net, char * url) in HTHost_listen() argument
1357 if (!host) { in HTHost_listen()
1359 if ((host = HTHost_newWParse(request, url, HTProtocol_id(protocol))) == NULL) in HTHost_listen()
1367 if (!host->lock && !host->channel) { in HTHost_listen()
1368 host->forceWriteFlush = YES; in HTHost_listen()
1369 host->lock = net; in HTHost_listen()
1371 HTNet_setHost(net, host); in HTHost_listen()
1378 if (!host->listening) host->listening = HTNet_new(host); in HTHost_listen()
1383 status = HTDoListen(host->listening, net, HT_BACKLOG); in HTHost_listen()
1385 HTTRACE(CORE_TRACE, "Host listen. On Host %p resulted in %d\n" _ host _ status); in HTHost_listen()
1391 PUBLIC int HTHost_accept (HTHost * host, HTNet * net, char * url) in HTHost_accept() argument
1394 if (!host || !host->listening) { in HTHost_accept()
1399 if (!host->lock || (host->lock && host->lock == net)) { in HTHost_accept()
1400 status = HTDoAccept(host->listening, net); in HTHost_accept()
1404 host->lock = net; in HTHost_accept()
1413 if ((next_pending = HTList_firstObject(host->pending))) { in HTHost_accept()
1415 host _ next_pending); in HTHost_accept()
1416 host->lock = next_pending; in HTHost_accept()
1418 HTTRACE(CORE_TRACE, "Host connect Unlocking Host %p\n" _ host); in HTHost_accept()
1419 host->lock = NULL; in HTHost_accept()
1424 HTTRACE(CORE_TRACE, "Host connect Host %p already locked with %p\n" _ host _ host->lock); in HTHost_accept()
1425 if ((status = HTHost_addNet(host, net)) == HT_PENDING) { in HTHost_accept()
1436 PUBLIC int HTHost_register (HTHost * host, HTNet * net, HTEventType type) in HTHost_register() argument
1440 if (host && net) { in HTHost_register()
1447 HTEvent_unregister(HTChannel_socket(host->channel), HTEvent_READ); in HTHost_register()
1448 HTEvent_unregister(HTChannel_socket(host->channel), HTEvent_WRITE); in HTHost_register()
1449 host->registeredFor = 0; in HTHost_register()
1460 if (host->registeredFor & HTEvent_BITS(type)) in HTHost_register()
1462 host->registeredFor ^= HTEvent_BITS(type); in HTHost_register()
1466 event = *(host->events+HTEvent_INDEX(HTEvent_CLOSE)); in HTHost_register()
1467 HTEvent_register(HTChannel_socket(host->channel), HTEvent_CLOSE, event); in HTHost_register()
1471 event = *(host->events+HTEvent_INDEX(type)); in HTHost_register()
1473 return HTEvent_register(HTChannel_socket(host->channel), in HTHost_register()
1483 PUBLIC int HTHost_unregister (HTHost * host, HTNet * net, HTEventType type) in HTHost_unregister() argument
1485 if (host && net) { in HTHost_unregister()
1493 if (!(host->registeredFor & HTEvent_BITS(type))) in HTHost_unregister()
1495 host->registeredFor ^= HTEvent_BITS(type); in HTHost_unregister()
1499 if ((type == HTEvent_WRITE && isLastInPipe(host, net)) || in HTHost_unregister()
1502 HTEvent_unregister(HTChannel_socket(host->channel), type); in HTHost_unregister()
1511 PUBLIC BOOL HTHost_setRemainingRead (HTHost * host, size_t remaining) in HTHost_setRemainingRead() argument
1513 if (host == NULL) return NO; in HTHost_setRemainingRead()
1514 host->remainingRead = remaining; in HTHost_setRemainingRead()
1516 if (host->broken_pipe && remaining == 0) { in HTHost_setRemainingRead()
1522 PUBLIC size_t HTHost_remainingRead (HTHost * host) in HTHost_remainingRead() argument
1524 return host ? host->remainingRead : -1; in HTHost_remainingRead()
1527 PUBLIC SockA * HTHost_getSockAddr (HTHost * host) in HTHost_getSockAddr() argument
1529 if (!host) return NULL; in HTHost_getSockAddr()
1530 return &host->sock_addr; in HTHost_getSockAddr()
1533 PUBLIC BOOL HTHost_setHome (HTHost * host, int home) in HTHost_setHome() argument
1535 if (!host) return NO; in HTHost_setHome()
1536 host->home = home; in HTHost_setHome()
1540 PUBLIC int HTHost_home (HTHost * host) in HTHost_home() argument
1542 if (!host) return 0; in HTHost_home()
1543 return host->home; in HTHost_home()
1546 PUBLIC BOOL HTHost_setRetry (HTHost * host, int retry) in HTHost_setRetry() argument
1548 if (!host) return NO; in HTHost_setRetry()
1549 host->retry = retry; in HTHost_setRetry()
1553 PUBLIC BOOL HTHost_decreaseRetry (HTHost * host) in HTHost_decreaseRetry() argument
1555 if (!host) return NO; in HTHost_decreaseRetry()
1557 if (host->retry > 0) host->retry--; in HTHost_decreaseRetry()
1562 PUBLIC int HTHost_retry (HTHost * host) in HTHost_retry() argument
1564 if (!host) return 0; in HTHost_retry()
1565 return host->retry; in HTHost_retry()
1569 PRIVATE BOOL HTHost_setDNS5 (HTHost * host, HTdns * dns)
1571 if (!host) return NO;
1572 host->dns = dns;
1577 PUBLIC BOOL HTHost_setChannel (HTHost * host, HTChannel * channel) in HTHost_setChannel() argument
1579 if (!host) return NO; in HTHost_setChannel()
1580 host->channel = channel; in HTHost_setChannel()
1584 PUBLIC HTNet * HTHost_getReadNet(HTHost * host) in HTHost_getReadNet() argument
1586 return host ? (HTNet *) HTList_firstObject(host->pipeline) : NULL; in HTHost_getReadNet()
1589 PUBLIC HTNet * HTHost_getWriteNet(HTHost * host) in HTHost_getWriteNet() argument
1591 return host ? (HTNet *) HTList_lastObject(host->pipeline) : NULL; in HTHost_getWriteNet()
1598 PUBLIC HTInputStream * HTHost_getInput (HTHost * host, HTTransport * tp, in HTHost_getInput() argument
1601 if (host && host->channel && tp) { in HTHost_getInput()
1602 HTChannel * ch = host->channel; in HTHost_getInput()
1603 HTInputStream * input = (*tp->input_new)(host, ch, param, mode); in HTHost_getInput()
1611 PUBLIC HTOutputStream * HTHost_getOutput (HTHost * host, HTTransport * tp, in HTHost_getOutput() argument
1614 if (host && host->channel && tp) { in HTHost_getOutput()
1615 HTChannel * ch = host->channel; in HTHost_getOutput()
1616 HTOutputStream * output = (*tp->output_new)(host, ch, param, mode); in HTHost_getOutput()
1624 PUBLIC HTOutputStream * HTHost_output (HTHost * host, HTNet * net) in HTHost_output() argument
1626 if (host && host->channel && net) { in HTHost_output()
1627 HTOutputStream * output = HTChannel_output(host->channel); in HTHost_output()
1633 PUBLIC int HTHost_read(HTHost * host, HTNet * net) in HTHost_read() argument
1635 HTInputStream * input = HTChannel_input(host->channel); in HTHost_read()
1636 if (net != HTHost_getReadNet(host)) { in HTHost_read()
1637 HTHost_register(host, net, HTEvent_READ); in HTHost_read()
1650 PUBLIC BOOL HTHost_setConsumed(HTHost * host, size_t bytes) in HTHost_setConsumed() argument
1653 if (!host || !host->channel) return NO; in HTHost_setConsumed()
1654 if ((input = HTChannel_input(host->channel)) == NULL) in HTHost_setConsumed()
1660 PUBLIC int HTHost_hash (HTHost * host) in HTHost_hash() argument
1662 return host ? host->hash : -1; in HTHost_hash()
1665 PUBLIC BOOL HTHost_setWriteDelay (HTHost * host, ms_t delay) in HTHost_setWriteDelay() argument
1667 if (host && delay >= 0) { in HTHost_setWriteDelay()
1668 host->delay = delay; in HTHost_setWriteDelay()
1674 PUBLIC ms_t HTHost_writeDelay (HTHost * host) in HTHost_writeDelay() argument
1676 return host ? host->delay : 0; in HTHost_writeDelay()
1679 PUBLIC int HTHost_findWriteDelay (HTHost * host, ms_t lastFlushTime, int buffSize) in HTHost_findWriteDelay() argument
1684 int socket = HTChannel_socket(host->channel); in HTHost_findWriteDelay()
1688 if ((ret == 0 && buffSize >= mtu) || host->forceWriteFlush) in HTHost_findWriteDelay()
1690 return host->delay; in HTHost_findWriteDelay()
1692 return host->forceWriteFlush ? 0 : host->delay; in HTHost_findWriteDelay()
1711 PUBLIC int HTHost_forceFlush(HTHost * host) in HTHost_forceFlush() argument
1713 HTNet * targetNet = (HTNet *) HTList_lastObject(host->pipeline); in HTHost_forceFlush()
1721 if (host->inFlush) { in HTHost_forceFlush()
1728 host->forceWriteFlush = YES; in HTHost_forceFlush()
1729 host->inFlush = YES; in HTHost_forceFlush()
1730 …ret = (*targetNet->event.cbf)(HTChannel_socket(host->channel), targetNet->event.param, HTEvent_FLU… in HTHost_forceFlush()
1731 host->forceWriteFlush = NO; in HTHost_forceFlush()
1732 host->inFlush = NO; in HTHost_forceFlush()