summaryrefslogtreecommitdiff
path: root/src/gmrequest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmrequest.c')
-rw-r--r--src/gmrequest.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 8b87a638..8ab37c61 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -118,6 +118,8 @@ void deserialize_GmResponse(iGmResponse *d, iStream *ins) {
118 118
119/*----------------------------------------------------------------------------------------------*/ 119/*----------------------------------------------------------------------------------------------*/
120 120
121static iAtomicInt idGen_;
122
121enum iGmRequestState { 123enum iGmRequestState {
122 initialized_GmRequestState, 124 initialized_GmRequestState,
123 receivingHeader_GmRequestState, 125 receivingHeader_GmRequestState,
@@ -128,6 +130,7 @@ enum iGmRequestState {
128 130
129struct Impl_GmRequest { 131struct Impl_GmRequest {
130 iObject object; 132 iObject object;
133 uint32_t id;
131 iMutex * mtx; 134 iMutex * mtx;
132 iGmCerts * certs; /* not owned */ 135 iGmCerts * certs; /* not owned */
133 enum iGmRequestState state; 136 enum iGmRequestState state;
@@ -477,7 +480,8 @@ static void beginGopherConnection_GmRequest_(iGmRequest *d, const iString *host,
477/*----------------------------------------------------------------------------------------------*/ 480/*----------------------------------------------------------------------------------------------*/
478 481
479void init_GmRequest(iGmRequest *d, iGmCerts *certs) { 482void init_GmRequest(iGmRequest *d, iGmCerts *certs) {
480 d->mtx = new_Mutex(); 483 d->mtx = new_Mutex();
484 d->id = add_Atomic(&idGen_, 1) + 1;
481 d->resp = new_GmResponse(); 485 d->resp = new_GmResponse();
482 d->isFilterEnabled = iTrue; 486 d->isFilterEnabled = iTrue;
483 d->isRespLocked = iFalse; 487 d->isRespLocked = iFalse;
@@ -868,11 +872,18 @@ void unlockResponse_GmRequest(iGmRequest *d) {
868 } 872 }
869} 873}
870 874
875uint32_t id_GmRequest(const iGmRequest *d) {
876 return d ? d->id : 0;
877}
878
871iBool isFinished_GmRequest(const iGmRequest *d) { 879iBool isFinished_GmRequest(const iGmRequest *d) {
872 iBool done; 880 if (d) {
873 iGuardMutex(d->mtx, 881 iBool done;
874 done = (d->state == finished_GmRequestState || d->state == failure_GmRequestState)); 882 iGuardMutex(d->mtx,
875 return done; 883 done = (d->state == finished_GmRequestState || d->state == failure_GmRequestState));
884 return done;
885 }
886 return iTrue;
876} 887}
877 888
878enum iGmStatusCode status_GmRequest(const iGmRequest *d) { 889enum iGmStatusCode status_GmRequest(const iGmRequest *d) {