473,799 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cuncurrent access to file on network

To support a webfarm scenario, I'd like to store a global array (serialized)
in a file on a network share.
In this array there is a list of pages "locked" by other users so I need to
read this array at every page access to detect if the page is "free" so the
user can access it; when the user can access the page, the page is added to
the array so the next user can't access.
What's the best way to lock this (network) file so when 2 users access the
same page, the first user changes the array (writing to file) and the second
user can only read the file after the first user has finished the task?
FileShare.None throw an error if the filestream is already open...
Thanks in advance for support and sorry for my not-so-good english language
:)
Fabio
Nov 19 '05 #1
5 1529
I'm not 100% sure I understood but..
Are you saying you keep the pages that are "locked" in a text file and read
this in all the time? If so you have bigger issues. How do you clear a
"lock"? If the person closes their browser how do you release this?

Sounds like you may need to rethink things a little at a bigger level.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Fabio R." wrote:
To support a webfarm scenario, I'd like to store a global array (serialized)
in a file on a network share.
In this array there is a list of pages "locked" by other users so I need to
read this array at every page access to detect if the page is "free" so the
user can access it; when the user can access the page, the page is added to
the array so the next user can't access.
What's the best way to lock this (network) file so when 2 users access the
same page, the first user changes the array (writing to file) and the second
user can only read the file after the first user has finished the task?
FileShare.None throw an error if the filestream is already open...
Thanks in advance for support and sorry for my not-so-good english language
:)
Fabio

Nov 19 '05 #2
It works very fine, the array contains userid, pageid and the lock datetime:
locked pages are removed from array every time the same user access another
page while other pending lock are removed if older than session timeout.
For now I use a try / catch, when an IO Exception occur ("file is used by
another process") I use a Threading.Sleep to wait 10 milliseconds before
reading the file again.
Works locally, but I don't know if it will be stable when the application
will have 10-20 cuncurrent users reading/writing the file ( but a webserver
log file doesn't do the same? )...
Any suggestion / other methods?
Fabio

"Curt_C [MVP]" <software_at_da rkfalz.com> ha scritto nel messaggio
news:01******** *************** ***********@mic rosoft.com...
I'm not 100% sure I understood but..
Are you saying you keep the pages that are "locked" in a text file and
read
this in all the time? If so you have bigger issues. How do you clear a
"lock"? If the person closes their browser how do you release this?

Sounds like you may need to rethink things a little at a bigger level.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Fabio R." wrote:
To support a webfarm scenario, I'd like to store a global array
(serialized)
in a file on a network share.
In this array there is a list of pages "locked" by other users so I need
to
read this array at every page access to detect if the page is "free" so
the
user can access it; when the user can access the page, the page is added
to
the array so the next user can't access.
What's the best way to lock this (network) file so when 2 users access
the
same page, the first user changes the array (writing to file) and the
second
user can only read the file after the first user has finished the task?
FileShare.None throw an error if the filestream is already open...
Thanks in advance for support and sorry for my not-so-good english
language
:)
Fabio

Nov 19 '05 #3
DB may be better to track the locks (using the same cleanup practices) but if
what you have works then give it a shot I guess. I'm a bit concerned that the
file is opened/closed/read so much (every page load) that it may have issues
with scaling.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Fabio R." wrote:
It works very fine, the array contains userid, pageid and the lock datetime:
locked pages are removed from array every time the same user access another
page while other pending lock are removed if older than session timeout.
For now I use a try / catch, when an IO Exception occur ("file is used by
another process") I use a Threading.Sleep to wait 10 milliseconds before
reading the file again.
Works locally, but I don't know if it will be stable when the application
will have 10-20 cuncurrent users reading/writing the file ( but a webserver
log file doesn't do the same? )...
Any suggestion / other methods?
Fabio

"Curt_C [MVP]" <software_at_da rkfalz.com> ha scritto nel messaggio
news:01******** *************** ***********@mic rosoft.com...
I'm not 100% sure I understood but..
Are you saying you keep the pages that are "locked" in a text file and
read
this in all the time? If so you have bigger issues. How do you clear a
"lock"? If the person closes their browser how do you release this?

Sounds like you may need to rethink things a little at a bigger level.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Fabio R." wrote:
To support a webfarm scenario, I'd like to store a global array
(serialized)
in a file on a network share.
In this array there is a list of pages "locked" by other users so I need
to
read this array at every page access to detect if the page is "free" so
the
user can access it; when the user can access the page, the page is added
to
the array so the next user can't access.
What's the best way to lock this (network) file so when 2 users access
the
same page, the first user changes the array (writing to file) and the
second
user can only read the file after the first user has finished the task?
FileShare.None throw an error if the filestream is already open...
Thanks in advance for support and sorry for my not-so-good english
language
:)
Fabio


Nov 19 '05 #4
Mmm... DB probably (but I'm not sure) is more solid, but it's not slower
than reading the file? If it can be a better choice, how to lock the table
as I do with file?
Thanks,
Fabio

"Curt_C [MVP]" <software_at_da rkfalz.com> ha scritto nel messaggio
news:41******** *************** ***********@mic rosoft.com...
DB may be better to track the locks (using the same cleanup practices) but
if
what you have works then give it a shot I guess. I'm a bit concerned that
the
file is opened/closed/read so much (every page load) that it may have
issues
with scaling.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Fabio R." wrote:
It works very fine, the array contains userid, pageid and the lock
datetime:
locked pages are removed from array every time the same user access
another
page while other pending lock are removed if older than session timeout.
For now I use a try / catch, when an IO Exception occur ("file is used by
another process") I use a Threading.Sleep to wait 10 milliseconds before
reading the file again.
Works locally, but I don't know if it will be stable when the application
will have 10-20 cuncurrent users reading/writing the file ( but a
webserver
log file doesn't do the same? )...
Any suggestion / other methods?
Fabio

"Curt_C [MVP]" <software_at_da rkfalz.com> ha scritto nel messaggio
news:01******** *************** ***********@mic rosoft.com...
> I'm not 100% sure I understood but..
> Are you saying you keep the pages that are "locked" in a text file and
> read
> this in all the time? If so you have bigger issues. How do you clear a
> "lock"? If the person closes their browser how do you release this?
>
> Sounds like you may need to rethink things a little at a bigger level.
>
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
>
>
>
> "Fabio R." wrote:
>
>> To support a webfarm scenario, I'd like to store a global array
>> (serialized)
>> in a file on a network share.
>> In this array there is a list of pages "locked" by other users so I
>> need
>> to
>> read this array at every page access to detect if the page is "free"
>> so
>> the
>> user can access it; when the user can access the page, the page is
>> added
>> to
>> the array so the next user can't access.
>> What's the best way to lock this (network) file so when 2 users access
>> the
>> same page, the first user changes the array (writing to file) and the
>> second
>> user can only read the file after the first user has finished the
>> task?
>> FileShare.None throw an error if the filestream is already open...
>> Thanks in advance for support and sorry for my not-so-good english
>> language
>> :)
>> Fabio
>>
>>
>>


Nov 19 '05 #5
DB will be faster then file
Dont physically "lock" anything, just flag it as locked and look for the
flag for accessing

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Fabio R." wrote:
Mmm... DB probably (but I'm not sure) is more solid, but it's not slower
than reading the file? If it can be a better choice, how to lock the table
as I do with file?
Thanks,
Fabio

"Curt_C [MVP]" <software_at_da rkfalz.com> ha scritto nel messaggio
news:41******** *************** ***********@mic rosoft.com...
DB may be better to track the locks (using the same cleanup practices) but
if
what you have works then give it a shot I guess. I'm a bit concerned that
the
file is opened/closed/read so much (every page load) that it may have
issues
with scaling.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Fabio R." wrote:
It works very fine, the array contains userid, pageid and the lock
datetime:
locked pages are removed from array every time the same user access
another
page while other pending lock are removed if older than session timeout.
For now I use a try / catch, when an IO Exception occur ("file is used by
another process") I use a Threading.Sleep to wait 10 milliseconds before
reading the file again.
Works locally, but I don't know if it will be stable when the application
will have 10-20 cuncurrent users reading/writing the file ( but a
webserver
log file doesn't do the same? )...
Any suggestion / other methods?
Fabio

"Curt_C [MVP]" <software_at_da rkfalz.com> ha scritto nel messaggio
news:01******** *************** ***********@mic rosoft.com...
> I'm not 100% sure I understood but..
> Are you saying you keep the pages that are "locked" in a text file and
> read
> this in all the time? If so you have bigger issues. How do you clear a
> "lock"? If the person closes their browser how do you release this?
>
> Sounds like you may need to rethink things a little at a bigger level.
>
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
>
>
>
> "Fabio R." wrote:
>
>> To support a webfarm scenario, I'd like to store a global array
>> (serialized)
>> in a file on a network share.
>> In this array there is a list of pages "locked" by other users so I
>> need
>> to
>> read this array at every page access to detect if the page is "free"
>> so
>> the
>> user can access it; when the user can access the page, the page is
>> added
>> to
>> the array so the next user can't access.
>> What's the best way to lock this (network) file so when 2 users access
>> the
>> same page, the first user changes the array (writing to file) and the
>> second
>> user can only read the file after the first user has finished the
>> task?
>> FileShare.None throw an error if the filestream is already open...
>> Thanks in advance for support and sorry for my not-so-good english
>> language
>> :)
>> Fabio
>>
>>
>>


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
6050
by: MHenry | last post by:
Hi, We were going merrily along for 6 years using this database to record all client checks that came into our office, including information about what the checks were for. Suddenly, network computers cannot access the database. The message is...
6
12356
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't disappear from the ldb-file, before every user has closed the mdb-file. I have heard that there will be problems if the amount of users will be over 10 in mdb-files. Is that true? Hannu
16
48889
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use a commercial program such as Adobe Acrobat and its associated API. The technique uses Ghostscript and Redirection Port Monitor - two free programs for creating PDF documents provided free by Russell Lang. The actual automation requires VBA...
0
3293
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed comparison among SourceAnyWhere, SourceOffSite, VSS Remoting and possible others.
5
3114
by: Dave Kolb | last post by:
Is there any other solution for an ASPNET application to access network resources other than running as SYSTEM, using delegation (a nightmare to get to work) or the COM+ solution? I cannot seem to impersonate a user and obtain network credentials using the DuplicateTokenEx call with appropriate parameters even though the call seems to not fail. I check my identity has changed but can only still do local commands. I would consider...
1
2819
by: Microsoft News | last post by:
I have a web server sitting on computer 1, (QA1). Out on the network on my main server I have a folder with a zip file in it. All I want is for the web services that are on the web server to pick up the Zip file and send it when the web services are called. However I am getting the following error: -- Message: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ApplicationException:...
8
9764
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my problem: my vb.net program has problems with UNC. If the UNC server is restarted or goes off-line, my VB.net program crashes. The code for UNC access to the file is included below and is put in the tick event of a form timer control running every...
1
7870
by: shriil | last post by:
Hi I am facing a problem with regard to opening of Access Databases, resident on pcs of my office network connected thru LAN, from my machine on the network. The folders in which these databases reside are in full share mode and the folders are accessible. All the network machines including mine have Windows XP SP2 OS and Access 2002. All the versions are registered. Whenever I am double clicking an Access Database on the network, the...
10
6165
by: gary0gilbert | last post by:
An unusual spin to this recurring disk or network error in a Terminal Server environment. Access 2000, Terminal Server 2000, file server is windows 2000. All users have a separate copy of the front end db, everyone accesses the back-end db via a network share. To preface, non Terminal Server users (4 or 5 in office) never have this problem. There are two Terminal Servers running win 2000, both basically identical. This error affects...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10470
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.