I have some kernel threads in Linux kernel, inside my KLM.
I have a server thread, that listens to the channel, Once it sees there is an incoming connection, it creates an accept socket, accepts the connection and spawns a child thread. It also passes the accepted socket to the child kernel thread as the (void *) argument.
The code is working fine. I had a design question.
Suppose now the threads have to be terminated, main and the child threads, what would be the best way to close the accept socket. I can see two ways,
1] The main thread waits for all the child threads to exit, each of the child threads close the accept sockets while exiting, the last child thread passes a signal to the main thread for it to exit . Here even though the main thread was the one that created the accept socket, the child threads close that socket, and they do this before the main thread exits. So is this acceptable? Any problems you guys forsee here?
2] Second is the main thread closes all the accept sockets it created before it exits. But there may be a possibility(corner case) that the main thread gets an exception and will have to close, so if it closes the accept sockets before exiting, the child threads using that socket will be in danger.
Hence i am using the first case i mentioned.Let me know what you guys think?
Hi All,
I was googling for tools for checking broken links in a remote web page. The w3c validator seemed a good one. But I am still unsure as how to check for pages which are restricted, i.e. the pages which I can only access by logging in to the site. Can we do that using the w3c validator? If not than is there any other tool for the same?
Hello all,
Is there something simpler than the following.
I am trying to make a GET request to a PHP script and then exit the current script.
I think this is a job for CURL but is there something simpler as I don't want to really worry about enabling the CURL php extension?
In addition, will the below start the PHP script and then just come back and not wait for it to finish?
//set GET variables
$url = 'http://domain.com/get-post.php';
$fields = array(
'lname'=>urlencode($last_name),
'fname'=>urlencode($first_name)
);
//url-ify the data for the GET
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_GET,count($fields));
curl_setopt($ch,CURLOPT_GETFIELDS,$fields_string);
//execute GET
$result = curl_exec($ch);
//close connection
curl_close($ch);
I want to run the other script which contains functions when a condition is met so a simple include won't work as the if condition wraps around the functions, right?
Please note, I am on windows machine and the code I am writing will only be used on a Windows OS.
Thanks all for any help and advice
I've used ( and still use ) mercurial and git. I have some repos hosted in a server with gitosis which is great and easy to setup. I am looking for a similar tool for hosting mercurial repos.
It must provide minimal acl and ssh access and allow for remote config ( in the style of gitosis's "clone the admin repo and push changes" ).
Extra points for automating hgweb config via said tool.
Another annoying one for me but probably something simple.
I have a number of possible where clauses for a query based on user input, my question is how can I add these programmatically?
For instance:
wherequery = @"WHERE fieldname = @p_FieldName AND ";
if (txtValue.textLength > 0){
wherequery += "fieldname2 = @p_FieldName2 AND ";
}
query = @"SELECT * FROM tabe" + wherequery;
sql = connection.CreateCommand();
sql.CommandText = query;
How would I go about doing the parameters for that? I've tried ArrayLists, Dictionaries and a few other methods but can't find a way of doing it. Ideally I'd want to do something like this:
SqlParameter[] sqlparams;
wherequery = @"WHERE fieldname = @p_FieldName AND ";
if (txtValue.textLength > 0){
wherequery += "fieldname2 = @p_FieldName2 AND ";
sqlparams.Parameters.Add("@p_FieldName2 ", SqlDbType.VarChar).Value = txtValue.text;
}
query = @"SELECT * FROM tabe" + wherequery;
sql = connection.CreateCommand();
sql.CommandText = query;
sql.Parameters.Add(sqlparams);
I want to access a MySQL database from Java, but remoteconnection is disabled by the host.
So I will send the data to PHP and then PHP will locally access the database.
The data is pretty big (about 2~4kb)
I've never done this before.
What should I do?
Can I create an event so I can execute some javascript whenever an element with a specific ID becomes visible or appears on the page?
The element comes from a remote resource (so isn't in MY html code but appears on page load) and I'd like some code to run when it appears (and only if it appears, it may not appear every load).
Thanks!
Within a minute of connecting to my remote Linux server through SSH, my session times out and I cannot contact the server until a few seconds have passed. Meanwhile, I'm connected to other servers without interruption. This is only happening when I establish connection from an hotel wireless AP. When I connect from my phone's Internet, the problem does not occur. Does anyone know what might be causing these unusual timeouts?
How do I set the redeliveryPolicy in ActiveMQ on a Queue?
1) In the doc, see: activeMQ Redelivery, the explain that you should set it on the ConnectionFactory or Connection. But I want to use different value's for different Queue's.
2) Apart from that, I don't seem to get it work. Setting it on the connection factory in Spring (I am using activemq 5.4.2. with Spring 3.0) like this don't seem to have any effect:
<amq:connectionFactory id="amqConnectionFactory" brokerURL="${jms.factory.url}" >
<amq:properties>
<amq:redeliveryPolicy maximumRedeliveries="6" initialRedeliveryDelay="15000" useExponentialBackOff="true" backOffMultiplier="5"/>
</amq:properties>
</amq:connectionFactory>
I also tried to set it as property on the defined Queue, but that also seem to be ignored as the redelivery occurs sooner that the defined values:
<amq:queue id="jmsQueueDeclarationSnd" physicalName="${jms.queue.declaration.snd}" >
<amq:properties>
<amq:redeliveryPolicy maximumRedeliveries="6" initialRedeliveryDelay="15000" useExponentialBackOff="true" backOffMultiplier="5"/>
</amq:properties>
</amq:queue>
Thanks
I am using Enterprise library 3.1 to log application logs in Windows event logs, and I want to read this log by passing the date parameter.
Please note that I will be accessing the remote machine and the performance should be good. Is there any method that can be used to read these logs using Ent Lib, or please suggest some good method.
I am importing data from another database.
My process is importing data from a remote DB into a List<DataModel> named remoteData and also importing data from the local DB into a List<DataModel> named localData.
I am then using LINQ to create a list of records that are different so that I can update the local DB to match the data pulled from remote DB. Like this:
var outdatedData = this.localData.Intersect(this.remoteData, new OutdatedDataComparer()).ToList();
I am then using LINQ to create a list of records that no longer exist in remoteData, but do exist in localData, so that I delete them from local database.
Like this:
var oldData = this.localData.Except(this.remoteData, new MatchingDataComparer()).ToList();
I am then using LINQ to do the opposite of the above to add the new data to the local database.
Like this:
var newData = this.remoteData.Except(this.localData, new MatchingDataComparer()).ToList();
Each collection imports about 70k records, and each of the 3 LINQ operation take between 5 - 10 minutes to complete. How can I make this faster?
Here is the object the collections are using:
internal class DataModel
{
public string Key1{ get; set; }
public string Key2{ get; set; }
public string Value1{ get; set; }
public string Value2{ get; set; }
public byte? Value3{ get; set; }
}
The comparer used to check for outdated records:
class OutdatedDataComparer : IEqualityComparer<DataModel>
{
public bool Equals(DataModel x, DataModel y)
{
var e =
string.Equals(x.Key1, y.Key1) &&
string.Equals(x.Key2, y.Key2) && (
!string.Equals(x.Value1, y.Value1) ||
!string.Equals(x.Value2, y.Value2) ||
x.Value3 != y.Value3
);
return e;
}
public int GetHashCode(DataModel obj)
{
return 0;
}
}
The comparer used to find old and new records:
internal class MatchingDataComparer : IEqualityComparer<DataModel>
{
public bool Equals(DataModel x, DataModel y)
{
return string.Equals(x.Key1, y.Key1) && string.Equals(x.Key2, y.Key2);
}
public int GetHashCode(DataModel obj)
{
return 0;
}
}
Hey
I'd like to know how to use XMLHttpRequest to load the content of a remote URL and have the HTML of the accessed site stored in a JS variable.
Say, if I wanted to load and alert() the HTML of http://foo.com/bar.php, how would I do that?
Thanks!
In one of our existing C programs which purpose is:
Open connection to DB
for record in all_record:
if record contain certain data:
if record is NOT in table A: // see #1
insert record information into table A and B // see #2
Close connection to DB
select field from table where field=XXX
2 inserts
This is typically done every X months to sync everything up or so I'm told. I've also been told that this process takes roughly a couple of days. There is (currently) at most 2.5million records (though not necessarily all 2.5m will be inserted). One of the table contains 10 fields and the other 5 fields. There isn't much to be done about iterating through the records since that part can't be changed at the moment. What I would like to do is speed up the part where I query MySQL.
I'm not sure if I have left out any important details -- please let me know! I'm also no SQL expert so feel free to point out the obvious.
I thought about:
Putting all the inserts into a transaction (at the moment I'm not sure how important it is for the transaction to be all-or-none or if this affects performance)
Using Insert X Where Not Exists Y
LOAD DATA INFILE (but that would require I create a (possibly) large temp file)
I read that (hopefully someone can confirm) I should drop indexes so they aren't re-calculated.
mysql Ver 14.7 Distrib 4.1.22, for sun-solaris2.10 (sparc) using readline 4.3
Hi, I have a Windows domain within which a machine is running SQL Server 2005 and which is configured to support only Windows authentication. I would like to run a C# client application on a machine on the same network, but which is NOT on the domain, and access a database on the SQL Server 2005 instance.
I thought that it would be a simple matter of doing something like this:
string connectionString = "Data Source=server;Initial Catalog=database;User Id=domain\user;Password=password";
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
However, this fails: the client-side error is:
System.Data.SqlClient.SqlException: Login failed for user 'domain\user'
and the server-side error is: Error 18456, Severity 14, State 5
I have tried various things including setting integrated security to true and false, and \ instead of \ in the User Id, but without success.
In general, I know that it possible to connect to the SQL Server 2005 instance from a non-domain machine (for example, I am working with a Linux-based application which happily does this), but I don't seem to be able to work out how to do it from a Windows machine.
Help would be appreciated! Thanks, Martin
im new in vb, i was create a program to connection ms access but when i run the program it get syntax error in Insert into statement, OleDbExpection was unhandled
here my code
Public Class Form2
Dim cnn As New OleDb.OleDbConnection
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtdate.Value = DateTime.Now
cnn = New OleDb.OleDbConnection
cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=C:\Users\John\Documents\db.mdb"
End Sub
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
Dim cmd As New OleDb.OleDbCommand
cmd.Connection = cnn
cmd.CommandText = "INSERT INTO sr(names,add,tel,dates,prob,serv,model,snm,acc,sna,remark)" & _
"VALUES ('" & Me.txtname.Text & "','" & Me.txtadd.Text & "','" & Me.txttel.Text & "', '" & _
Me.txtdate.Text & "','" & Me.txtpro.Text & "','" & Me.txtser.Text & "','" & Me.txtmod.Text & "', '" & _
Me.txtsnm.Text & "','" & Me.txtacc.Text & "','" & Me.txtsna.Text & "','" & Me.txtrem.Text & "')"
cmd.ExecuteNonQuery()
cnn.Close()
End Sub
End Class
it's there any wrong with my code?
I get an "The remote name could not be resolved: 'mine.com'"
When using this open ID identifier:
https://www.google.com/accounts/o8/site-xrds?hd=mine.com
And it's true, that the mine.com DNS record doesn't exist. But I'm wondering why it goes to look there in the first place. All I want to be doing is to check if the user can login to our hosted domain. Is that really so hard?
I have created a socket using the following lines of code.
Now i change the value of the socket i get like this
m_Socket++;
Even now the send recv socket functions succeeds without throwing SOCKET_ERROR.
I expect that it must throw error.
Am i doing something wrong.
struct sockaddr_in ServerSock; // Socket address structure to bind the Port Number to listen to
char *localIP ;
SOCKET SocServer;
//To Set up the sockaddr structure
ServerSock.sin_family = AF_INET;
ServerSock.sin_addr.s_addr = INADDR_ANY;
ServerSock.sin_port = htons(pLantronics->m_wRIPortNo);
// To Create a socket for listening on wPortNumber
if(( SocServer = socket( AF_INET, SOCK_STREAM, 0 )) == INVALID_SOCKET )
{
return FALSE;
}
//To bind the socket with wPortNumber
if(bind(SocServer,(sockaddr*)&ServerSock,sizeof(ServerSock))!=0)
{
return FALSE;
}
// To Listen for the connection on wPortNumber
if(listen(SocServer,SOMAXCONN)!=0)
{
return FALSE;
}
// Structure to get the IP Address of the connecting Entity
sockaddr_in insock;
int insocklen=sizeof(insock);
//To accept the Incoming connection on the wPortNumber
pLantronics->m_Socket=accept(SocServer,(struct sockaddr*)&insock,&insocklen);
if(pLantronics->m_Socket == INVALID_SOCKET)
{
shutdown(SocServer, 2 );
closesocket(SocServer );
return FALSE;
}
// To make socket non-blocking
DWORD dwNonBlocking = 1;
if(ioctlsocket( pLantronics->m_Socket, FIONBIO, &dwNonBlocking ))
{
shutdown(pLantronics->m_Socket, 2);
closesocket(pLantronics->m_Socket);
return FALSE;
}
pLantronics->m_sModemName = inet_ntoa(insock.sin_addr);
Now i do
m_Socket++;//change to some other number ideally expecting send recv to fail.
Even now the send recv socket functions succeeds without throwing SOCKET_ERROR.
I expect that it must throw error.
Am i doing something wrong.
Recently i designed one Abode air Chat application, which gets the chat messages from admin-Application(we bApplication), band width consumption is too high while each client launching air application to pull the data from database to my-amf endpoint.
in this am using blazeds,Jetty server,simple java classes(not servlets) calling with remote object,
Please any one suggest me few techiniques to
1)reduce the bandwidh consumption while sending message to each client from admin
2)minimize the time to pull the data from database while client launching application.
Regards,
Thirst for Excellence
I'm developing a site which monitors user's date.
It uses the cURL over PHP.
It first gets authorized using cookie and then parses the required data.
My problem is that it needs to fire multiple requests to the server (for all registered users) and this may
Get me banned by the remote server.
I would like to know if there is something I could do to prevent being banned.
(This activity is legal - the users have provided their login information)
Thanks
i need the source code of an application that can upload and download automatically from the remote computer (FTP) using java langauge. if any body gey help or the code, kindly contact me through my mail address [email protected]. thanks
Hi all,
How can I use WMIUserID, WMIPassword, WMIAlternateCredentials using C#?
Also, is it possible to get remote computer's Administrator-password?
Please try to explain with examples.
Thanks.
In CVS, we could programatically create a new branch of existing source using the "rtag" command, which did not require a copy of the repository.
Does git support functionality of this kind, making a branch of existing files in a remote git repository without having a local copy of it? Or does the distributed nature of git preclude this?
(I'm trying to save the 20+ minutes it would take to make a freestanding copy of the repository, just to run a 'git branch' command.)
Hi,
I have a simple SQL insert statement of the form:
insert into MyTable (...) values (...)
It is used repeatedly to insert rows and usually works as expected. It inserts exactly 1 row to MyTable, which is also the value returned by the Delphi statement AffectedRows:= myInsertADOQuery.ExecSQL.
After some time there was a temporary network connectivity problem. As a result, other threads of the same application perceived EOleExceptions (Connection failure, -2147467259 = unspecified error). Later, the network connection was reestablished, these threads reconnected and were fine.
The thread responsible for executing the insert statement described above, however, did not perceive the connectivity problems (No exceptions) - probably it was simply not executed while the network was down. But after the network connectivity problems myInsertADOQuery.ExecSQL always returned 0 and no rows were inserted to MyTable anymore. After a restart of the application the insert statement worked again as expected.
For SQL Server, is there any defined case where an insert statment like the one above would not insert a row and return 0 as the number of affected rows? Primary key is an autogenerated GUID. There are no unique or check constraints (which should result in an exception anyway rather than not inserting a row).
Are there any known ADO bugs (Provider=SQLOLEDB.1)?
Any other explanations for this behaviour?
Thanks,
Nang.