Diff

Differences From Artifact [ccad9f7f2c]:

To Artifact [7b136bd4a6]:


106
107
108
109
110
111
112


113
114
115
116
117
118
119
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
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
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
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(0);
	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
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) {