Check-in [aa08a4a749]
Overview
Comment:Updated to keep track of whether or not there were events queued before closing and freeing a structure
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: aa08a4a74968dcddbad934ade8920da2cd0bf459c9e7683374b2f5d1325383b7
User & Date: rkeene on 2019-09-14 00:54:24
Other Links: manifest | tags
Context
2019-09-14
03:59
Added matchInDir support check-in: 5583d77f1c user: rkeene tags: trunk
00:54
Updated to keep track of whether or not there were events queued before closing and freeing a structure check-in: aa08a4a749 user: rkeene tags: trunk
2019-09-13
21:46
Watch proc and more tests check-in: 7d74392642 user: rkeene tags: trunk
Changes

Modified example/main.tcl from [c2846bcc7a] to [6323624de5].

41
42
43
44
45
46
47


48
49
vwait done
if {$calls != ($size + 1)} {
	error "EXPECTED [expr {$size + 1}], got $calls"
}
if {[lsort -integer $output] != $output} {
	error "EXPECTED [lsort -integer $output], GOT $output"
}



puts "ALL TESTS PASSED"







>
>


41
42
43
44
45
46
47
48
49
50
51
vwait done
if {$calls != ($size + 1)} {
	error "EXPECTED [expr {$size + 1}], got $calls"
}
if {[lsort -integer $output] != $output} {
	error "EXPECTED [lsort -integer $output], GOT $output"
}
close $fd
update idle

puts "ALL TESTS PASSED"

Modified xvfs-core.c from [ccad9f7f2c] to [7b136bd4a6].

106
107
108
109
110
111
112


113
114
115
116
117
118
119
struct xvfs_tclfs_channel_id {
	Tcl_Channel channel;
	struct xvfs_tclfs_instance_info *fsInstanceInfo;
	Tcl_Obj *path;
	Tcl_WideInt currentOffset;
	Tcl_WideInt fileSize;
	int eofMarked;


};
struct xvfs_tclfs_channel_event {
	Tcl_Event tcl;
	struct xvfs_tclfs_channel_id *channelInstanceData;
};
static Tcl_ChannelType xvfs_tclfs_channelType;








>
>







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
struct xvfs_tclfs_channel_id {
	Tcl_Channel channel;
	struct xvfs_tclfs_instance_info *fsInstanceInfo;
	Tcl_Obj *path;
	Tcl_WideInt currentOffset;
	Tcl_WideInt fileSize;
	int eofMarked;
	int queuedEvents;
	int closed;
};
struct xvfs_tclfs_channel_event {
	Tcl_Event tcl;
	struct xvfs_tclfs_channel_id *channelInstanceData;
};
static Tcl_ChannelType xvfs_tclfs_channelType;

128
129
130
131
132
133
134


135
136
137
138
139
140
141
	if (statRet < 0) {
		return(NULL);
	}

	channelInstanceData = (struct xvfs_tclfs_channel_id *) Tcl_Alloc(sizeof(*channelInstanceData));
	channelInstanceData->currentOffset = 0;
	channelInstanceData->eofMarked = 0;


	channelInstanceData->channel = NULL;

	channelName = Tcl_ObjPrintf("xvfs0x%llx", (unsigned long long) channelInstanceData);
	if (!channelName) {
		Tcl_Free((char *) channelInstanceData);

		return(NULL);







>
>







130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
	if (statRet < 0) {
		return(NULL);
	}

	channelInstanceData = (struct xvfs_tclfs_channel_id *) Tcl_Alloc(sizeof(*channelInstanceData));
	channelInstanceData->currentOffset = 0;
	channelInstanceData->eofMarked = 0;
	channelInstanceData->queuedEvents = 0;
	channelInstanceData->closed = 0;
	channelInstanceData->channel = NULL;

	channelName = Tcl_ObjPrintf("xvfs0x%llx", (unsigned long long) channelInstanceData);
	if (!channelName) {
		Tcl_Free((char *) channelInstanceData);

		return(NULL);
156
157
158
159
160
161
162















163
164
165

166
167















168
169
170
171
172
173
174
		return(NULL);
	}

	channelInstanceData->channel = channel;

	return(channel);
}
















static int xvfs_tclfs_closeChannel(ClientData channelInstanceData_p, Tcl_Interp *interp) {
	struct xvfs_tclfs_channel_id *channelInstanceData;


	channelInstanceData = (struct xvfs_tclfs_channel_id *) channelInstanceData_p;
















	Tcl_DecrRefCount(channelInstanceData->path);
	Tcl_Free((char *) channelInstanceData);

	return(0);
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
		return(NULL);
	}

	channelInstanceData->channel = channel;

	return(channel);
}

static int xvfs_tclfs_closeChannel(ClientData channelInstanceData_p, Tcl_Interp *interp);
static int xvfs_tclfs_closeChannelEvent(Tcl_Event *event_p, int flags) {
	struct xvfs_tclfs_channel_id *channelInstanceData;
	struct xvfs_tclfs_channel_event *event;

	event = (struct xvfs_tclfs_channel_event *) event_p;
	channelInstanceData = event->channelInstanceData;

	channelInstanceData->queuedEvents--;

	xvfs_tclfs_closeChannel((ClientData) channelInstanceData, NULL);

	return(1);
}

static int xvfs_tclfs_closeChannel(ClientData channelInstanceData_p, Tcl_Interp *interp) {
	struct xvfs_tclfs_channel_id *channelInstanceData;
	struct xvfs_tclfs_channel_event *event;

	channelInstanceData = (struct xvfs_tclfs_channel_id *) channelInstanceData_p;

	channelInstanceData->closed = 1;

	if (channelInstanceData->queuedEvents != 0) {
		event = (struct xvfs_tclfs_channel_event *) Tcl_Alloc(sizeof(*event));
		event->tcl.proc = xvfs_tclfs_closeChannelEvent;
		event->tcl.nextPtr = NULL;
		event->channelInstanceData = channelInstanceData;

		channelInstanceData->queuedEvents++;

		Tcl_QueueEvent((Tcl_Event *) event, TCL_QUEUE_TAIL);

		return(0);
	}

	Tcl_DecrRefCount(channelInstanceData->path);
	Tcl_Free((char *) channelInstanceData);

	return(0);
}

213
214
215
216
217
218
219






220
221
222
223
224
225
226
227
228
229
230

static int xvfs_tclfs_watchChannelEvent(Tcl_Event *event_p, int flags) {
	struct xvfs_tclfs_channel_id *channelInstanceData;
	struct xvfs_tclfs_channel_event *event;

	event = (struct xvfs_tclfs_channel_event *) event_p;
	channelInstanceData = event->channelInstanceData;







	Tcl_NotifyChannel(channelInstanceData->channel, TCL_READABLE);

	return(0);
}

static void xvfs_tclfs_watchChannel(ClientData channelInstanceData_p, int mask) {
	struct xvfs_tclfs_channel_id *channelInstanceData;
	struct xvfs_tclfs_channel_event *event;

	if ((mask & TCL_READABLE) != TCL_READABLE) {







>
>
>
>
>
>



|







248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271

static int xvfs_tclfs_watchChannelEvent(Tcl_Event *event_p, int flags) {
	struct xvfs_tclfs_channel_id *channelInstanceData;
	struct xvfs_tclfs_channel_event *event;

	event = (struct xvfs_tclfs_channel_event *) event_p;
	channelInstanceData = event->channelInstanceData;

	channelInstanceData->queuedEvents--;

	if (channelInstanceData->closed) {
		return(1);
	}

	Tcl_NotifyChannel(channelInstanceData->channel, TCL_READABLE);

	return(1);
}

static void xvfs_tclfs_watchChannel(ClientData channelInstanceData_p, int mask) {
	struct xvfs_tclfs_channel_id *channelInstanceData;
	struct xvfs_tclfs_channel_event *event;

	if ((mask & TCL_READABLE) != TCL_READABLE) {
241
242
243
244
245
246
247


248
249
250
251
252
253
254
		return;
	}

	event = (struct xvfs_tclfs_channel_event *) Tcl_Alloc(sizeof(*event));
	event->tcl.proc = xvfs_tclfs_watchChannelEvent;
	event->tcl.nextPtr = NULL;
	event->channelInstanceData = channelInstanceData;



	Tcl_QueueEvent((Tcl_Event *) event, TCL_QUEUE_TAIL);

	return;
}

static int xvfs_tclfs_seekChannel(ClientData channelInstanceData_p, long offset, int mode, int *errorCodePtr) {







>
>







282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
		return;
	}

	event = (struct xvfs_tclfs_channel_event *) Tcl_Alloc(sizeof(*event));
	event->tcl.proc = xvfs_tclfs_watchChannelEvent;
	event->tcl.nextPtr = NULL;
	event->channelInstanceData = channelInstanceData;

	channelInstanceData->queuedEvents++;

	Tcl_QueueEvent((Tcl_Event *) event, TCL_QUEUE_TAIL);

	return;
}

static int xvfs_tclfs_seekChannel(ClientData channelInstanceData_p, long offset, int mode, int *errorCodePtr) {